diff --git a/src/TensorFlowNET.Core/Python.cs b/src/TensorFlowNET.Core/Python.cs index 6f5d304f..a1c377dd 100644 --- a/src/TensorFlowNET.Core/Python.cs +++ b/src/TensorFlowNET.Core/Python.cs @@ -1,4 +1,5 @@ -using System; +using NumSharp.Core; +using System; using System.Collections.Generic; using System.Text; @@ -51,6 +52,16 @@ namespace Tensorflow py.Dispose(); } } + + public static (T, T) zip(T t1, T t2, int index = 0) where T : IList + { + return (t1[index], t2[index]); + } + + public static (T, T) zip(NDArray t1, NDArray t2, int index = 0) + { + return (t1.Data(index), t2.Data(index)); + } } public interface IPython : IDisposable diff --git a/test/TensorFlowNET.Examples/HelloWorld.cs b/test/TensorFlowNET.Examples/HelloWorld.cs index ce600097..1c57d5ca 100644 --- a/test/TensorFlowNET.Examples/HelloWorld.cs +++ b/test/TensorFlowNET.Examples/HelloWorld.cs @@ -25,10 +25,10 @@ namespace TensorFlowNET.Examples { // Run the op var result = sess.run(hello); - Console.WriteLine(result); + Console.WriteLine(result.ToString()); if(!result.ToString().Equals("Hello, TensorFlow!")) { - throw new Exception("HelloWorld error"); + throw new ValueError("HelloWorld"); } } } diff --git a/test/TensorFlowNET.Examples/LinearRegression.cs b/test/TensorFlowNET.Examples/LinearRegression.cs index 3311b064..860036e0 100644 --- a/test/TensorFlowNET.Examples/LinearRegression.cs +++ b/test/TensorFlowNET.Examples/LinearRegression.cs @@ -59,6 +59,18 @@ namespace TensorFlowNET.Examples { // Run the initializer sess.run(init); + + // Fit all training data + for (int i = 0; i < training_epochs; i++) + { + for(int index = 0; index < train_X.size; index++) + { + (double x, double y) = Python.zip(train_X, train_Y, index); + var feed_dict = new Dictionary(); + + // sess.run(optimizer, feed_dict); + } + } }); } }