| @@ -1,5 +1,6 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | |||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | using System.Text; | ||||
| @@ -26,7 +27,7 @@ namespace TensorFlowNET.Core | |||||
| _nodes_by_name = new Dictionary<string, Operation>(); | _nodes_by_name = new Dictionary<string, Operation>(); | ||||
| } | } | ||||
| public unsafe Operation create_op(object inputs, string op_type = "", string name = "") | |||||
| public unsafe Operation create_op(string op_type, object inputs, TF_DataType[] dtypes, TF_DataType[] input_types = null, string name = "") | |||||
| { | { | ||||
| if (String.IsNullOrEmpty(name)) | if (String.IsNullOrEmpty(name)) | ||||
| { | { | ||||
| @@ -51,9 +52,9 @@ namespace TensorFlowNET.Core | |||||
| return ++_next_id_counter; | return ++_next_id_counter; | ||||
| } | } | ||||
| public void get_operations() | |||||
| public Operation[] get_operations() | |||||
| { | { | ||||
| return _nodes_by_name.Values.Select(x => x).ToArray(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -9,6 +9,10 @@ | |||||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <ItemGroup> | |||||
| <ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" /> | |||||
| </ItemGroup> | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <None Update="libtensorflow.dll"> | <None Update="libtensorflow.dll"> | ||||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
| @@ -3,8 +3,6 @@ using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | using System.Text; | ||||
| namespace TensorFlowNET.Core | namespace TensorFlowNET.Core | ||||
| { | { | ||||
| public static class Tensorflow | public static class Tensorflow | ||||
| @@ -14,7 +12,7 @@ namespace TensorFlowNET.Core | |||||
| public static unsafe Tensor constant(object value) | public static unsafe Tensor constant(object value) | ||||
| { | { | ||||
| var g = ops.get_default_graph(); | var g = ops.get_default_graph(); | ||||
| g.create_op(value, "Const"); | |||||
| g.create_op("Const", value, new TF_DataType[] { TF_DataType.TF_DOUBLE }); | |||||
| return new Tensor(); | return new Tensor(); | ||||
| } | } | ||||
| @@ -29,6 +27,11 @@ namespace TensorFlowNET.Core | |||||
| public static string VERSION => Marshal.PtrToStringAnsi(c_api.TF_Version()); | public static string VERSION => Marshal.PtrToStringAnsi(c_api.TF_Version()); | ||||
| public static Graph get_default_graph() | |||||
| { | |||||
| return ops.get_default_graph(); | |||||
| } | |||||
| public static Graph Graph() | public static Graph Graph() | ||||
| { | { | ||||
| Graph g = new Graph(c_api.TF_NewGraph()); | Graph g = new Graph(c_api.TF_NewGraph()); | ||||
| @@ -0,0 +1,15 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using np = NumSharp.Core.NumPy; | |||||
| namespace TensorFlowNET.Core | |||||
| { | |||||
| public static class tensor_util | |||||
| { | |||||
| public static void make_tensor_proto(object values, Type dtype = null) | |||||
| { | |||||
| var nparray = np.array(values as Array, dtype); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -18,6 +18,7 @@ namespace TensorFlowNET.Examples | |||||
| The value returned by the constructor represents the output | The value returned by the constructor represents the output | ||||
| of the Constant op.*/ | of the Constant op.*/ | ||||
| var graph = tf.get_default_graph(); | |||||
| var hello = tf.constant(4.0); | var hello = tf.constant(4.0); | ||||
| //var hello = tf.constant("Hello, TensorFlow!"); | //var hello = tf.constant("Hello, TensorFlow!"); | ||||