| @@ -1,4 +1,5 @@ | |||||
| using System; | |||||
| using NumSharp.Core; | |||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| @@ -51,6 +52,16 @@ namespace Tensorflow | |||||
| py.Dispose(); | py.Dispose(); | ||||
| } | } | ||||
| } | } | ||||
| public static (T, T) zip<T>(T t1, T t2, int index = 0) where T : IList<T> | |||||
| { | |||||
| return (t1[index], t2[index]); | |||||
| } | |||||
| public static (T, T) zip<T>(NDArray t1, NDArray t2, int index = 0) | |||||
| { | |||||
| return (t1.Data<T>(index), t2.Data<T>(index)); | |||||
| } | |||||
| } | } | ||||
| public interface IPython : IDisposable | public interface IPython : IDisposable | ||||
| @@ -25,10 +25,10 @@ namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| // Run the op | // Run the op | ||||
| var result = sess.run(hello); | var result = sess.run(hello); | ||||
| Console.WriteLine(result); | |||||
| Console.WriteLine(result.ToString()); | |||||
| if(!result.ToString().Equals("Hello, TensorFlow!")) | if(!result.ToString().Equals("Hello, TensorFlow!")) | ||||
| { | { | ||||
| throw new Exception("HelloWorld error"); | |||||
| throw new ValueError("HelloWorld"); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -59,6 +59,18 @@ namespace TensorFlowNET.Examples | |||||
| { | { | ||||
| // Run the initializer | // Run the initializer | ||||
| sess.run(init); | 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<double>(train_X, train_Y, index); | |||||
| var feed_dict = new Dictionary<Tensor, NDArray>(); | |||||
| // sess.run(optimizer, feed_dict); | |||||
| } | |||||
| } | |||||
| }); | }); | ||||
| } | } | ||||
| } | } | ||||