package cz.jurankovi.tensorflow;

import static org.bytedeco.javacpp.tensorflow.DT_FLOAT;
import static org.bytedeco.javacpp.tensorflow.InitMain;
import static org.bytedeco.javacpp.tensorflow.ReadBinaryProto;

import java.nio.FloatBuffer;

import org.bytedeco.javacpp.tensorflow.Env;
import org.bytedeco.javacpp.tensorflow.GraphDef;
import org.bytedeco.javacpp.tensorflow.Session;
import org.bytedeco.javacpp.tensorflow.SessionOptions;
import org.bytedeco.javacpp.tensorflow.Status;
import org.bytedeco.javacpp.tensorflow.StringTensorPairVector;
import org.bytedeco.javacpp.tensorflow.StringVector;
import org.bytedeco.javacpp.tensorflow.Tensor;
import org.bytedeco.javacpp.tensorflow.TensorShape;
import org.bytedeco.javacpp.tensorflow.TensorVector;

public class MultiplyTest {

	public static void main(String args[]) throws Exception {
		InitMain("trainer", (int[]) null, null);

		GraphDef def = new GraphDef();
		ReadBinaryProto(Env.Default(), "/tmp/my-model/train.pb", def);
		SessionOptions options = new SessionOptions();
		try (final Session session = new Session(options)) {

			Status s = session.Create(def);
			if (!s.ok()) {
				throw new RuntimeException(s.error_message().getString());
			}

			Tensor a = new Tensor(DT_FLOAT, new TensorShape(3, 1));
			Tensor b = new Tensor(DT_FLOAT, new TensorShape(3, 1));
			FloatBuffer aVal = a.createBuffer();
			aVal.put(new float[] { 2.0f, 3.0f, 4.0f });
			FloatBuffer bVal = b.createBuffer();
			bVal.put(new float[] { 3.0f, 4.0f, 5.0f });

			Tensor c = new Tensor(DT_FLOAT, new TensorShape(3, 1));
			TensorVector outputs = new TensorVector();
			s = session.Run(
					new StringTensorPairVector(new String[] { "Placeholder", "Placeholder_1" }, new Tensor[] { a, b }),
					new StringVector("Mul"), new StringVector("Mul"), outputs);

			if (!s.ok()) {
				throw new RuntimeException(s.error_message().getString());
			}

			FloatBuffer output = outputs.get(0).createBuffer();
			for (int i = 0; i < output.limit(); i++) {
				System.out.println("output: " + output.get(i));
			}
		}

	}

}

@@ -76,21 +76,22 @@
 flow.DT_
-FLOAT
+DOUBLE
 ;%0Aimport
@@ -220,21 +220,22 @@
 ava.nio.
-Float
+Double
 Buffer;%0A
@@ -960,21 +960,21 @@
 y-model/
-train
+basic
 .pb%22, de
@@ -1081,17 +1081,16 @@
 ons)) %7B%0A
-%0A
 %09%09%09Statu
@@ -1092,16 +1092,20 @@
 Status s
+ess 
  = sessi
@@ -1127,91 +1127,8 @@
 %0A%09%09%09
-if (!s.ok()) %7B%0A%09%09%09%09throw new RuntimeException(s.error_message().getString());%0A%09%09%09%7D%0A
 %0A%09%09%09
@@ -1134,17 +1134,17 @@
 %09Tensor 
-a
+x
  = new T
@@ -1144,37 +1144,38 @@
 = new Tensor(DT_
-FLOAT
+DOUBLE
 , new TensorShap
@@ -1194,17 +1194,17 @@
 %09Tensor 
-b
+y
  = new T
@@ -1204,37 +1204,38 @@
 = new Tensor(DT_
-FLOAT
+DOUBLE
 , new TensorShap
@@ -1251,28 +1251,30 @@
 %0A%09%09%09
-Float
+Double
 Buffer 
-aVal = a
+xBuff = x
 .cre
@@ -1293,12 +1293,13 @@
 %0A%09%09%09
-aVal
+xBuff
 .put
@@ -1307,21 +1307,22 @@
 new 
-float
+double
 %5B%5D %7B 2.0
 f, 3
@@ -1321,29 +1321,26 @@
  2.0
-f
 , 3.0
-f
 , 4.0
-f
  %7D);%0A%09%09%09
 Floa
@@ -1339,28 +1339,30 @@
 %0A%09%09%09
-Float
+Double
 Buffer 
-bVal = b
+yBuff = y
 .cre
@@ -1381,12 +1381,13 @@
 %0A%09%09%09
-bVal
+yBuff
 .put
@@ -1395,21 +1395,22 @@
 new 
-float
+double
 %5B%5D %7B 3.0
 f, 4
@@ -1409,86 +1409,24 @@
  3.0
-f
 , 4.0
-f
 , 5.0
-f
  %7D);%0A%0A
-%09%09%09Tensor c = new Tensor(DT_FLOAT, new TensorShape(3, 1));%0A
 %09%09%09T
@@ -1471,16 +1471,19 @@
 ();%0A%09%09%09s
+ess
  = sessi
@@ -1590,12 +1590,12 @@
 %5D %7B 
-a, b
+x, y
  %7D),
@@ -1670,16 +1670,19 @@
 %09%09if (!s
+ess
 .ok()) %7B
@@ -1714,16 +1714,19 @@
 eption(s
+ess
 .error_m
@@ -1761,13 +1761,14 @@
 %0A%09%09%09
-Float
+Double
 Buff

Update basic model