| @@ -1,9 +1,8 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class BaseSession | public class BaseSession | ||||
| { | { | ||||
| @@ -2,9 +2,8 @@ | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class Buffer | public class Buffer | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| namespace TensorFlowNET.Core.Eager | |||||
| namespace Tensorflow.Eager | |||||
| { | { | ||||
| public class Context | public class Context | ||||
| { | { | ||||
| @@ -3,10 +3,9 @@ using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| using TF_DataType = Tensorflow.DataType; | using TF_DataType = Tensorflow.DataType; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// TensorFlow uses a dataflow graph to represent your computation in terms of the dependencies between individual operations. | /// TensorFlow uses a dataflow graph to represent your computation in terms of the dependencies between individual operations. | ||||
| @@ -2,7 +2,7 @@ | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public sealed class MonoPInvokeCallbackAttribute : Attribute | public sealed class MonoPInvokeCallbackAttribute : Attribute | ||||
| { | { | ||||
| @@ -3,10 +3,9 @@ using System.Collections.Generic; | |||||
| using System.IO; | using System.IO; | ||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| using static Tensorflow.OpDef.Types; | using static Tensorflow.OpDef.Types; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class OpDefLibrary | public class OpDefLibrary | ||||
| { | { | ||||
| @@ -39,7 +38,9 @@ namespace TensorFlowNET.Core | |||||
| name = op_type_name; | name = op_type_name; | ||||
| } | } | ||||
| foreach(var attr_def in op_def.Attr) | |||||
| string scope = g.unique_name(name) + "/"; | |||||
| foreach (var attr_def in op_def.Attr) | |||||
| { | { | ||||
| if (attr_def.Type != "type") continue; | if (attr_def.Type != "type") continue; | ||||
| var key = attr_def.Name; | var key = attr_def.Name; | ||||
| @@ -84,7 +85,7 @@ namespace TensorFlowNET.Core | |||||
| } | } | ||||
| var op = g.create_op(op_type_name, null, output_types.ToArray(), | var op = g.create_op(op_type_name, null, output_types.ToArray(), | ||||
| name: "Placeholder_1/", | |||||
| name: scope, | |||||
| input_types: new DataType[] { }, | input_types: new DataType[] { }, | ||||
| attrs: attr_protos, | attrs: attr_protos, | ||||
| op_def: op_def); | op_def: op_def); | ||||
| @@ -1,10 +1,9 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| using TF_DataType = Tensorflow.DataType; | using TF_DataType = Tensorflow.DataType; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class Operation | public class Operation | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class Session : BaseSession | public class Session : BaseSession | ||||
| { | { | ||||
| @@ -1,9 +1,8 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class Status | public class Status | ||||
| { | { | ||||
| @@ -1,9 +1,8 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class Tensor | public class Tensor | ||||
| { | { | ||||
| @@ -2,6 +2,8 @@ | |||||
| <PropertyGroup> | <PropertyGroup> | ||||
| <TargetFramework>netstandard2.0</TargetFramework> | <TargetFramework>netstandard2.0</TargetFramework> | ||||
| <AssemblyName>TensorFlow.NET</AssemblyName> | |||||
| <RootNamespace>Tensorflow</RootNamespace> | |||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||||
| @@ -3,10 +3,8 @@ using NumSharp.Core; | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| using tensor_shape_pb2 = Tensorflow; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class TensorShape : Shape | public class TensorShape : Shape | ||||
| { | { | ||||
| @@ -1,13 +0,0 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Runtime.InteropServices; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| [StructLayout(LayoutKind.Sequential)] | |||||
| public struct TF_Graph | |||||
| { | |||||
| } | |||||
| } | |||||
| @@ -12,10 +12,8 @@ using TF_Session = System.IntPtr; | |||||
| using TF_SessionOptions = System.IntPtr; | using TF_SessionOptions = System.IntPtr; | ||||
| using TF_DataType = Tensorflow.DataType; | using TF_DataType = Tensorflow.DataType; | ||||
| using Tensorflow; | |||||
| using static TensorFlowNET.Core.tf; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public static class c_api | public static class c_api | ||||
| { | { | ||||
| @@ -40,7 +38,7 @@ namespace TensorFlowNET.Core | |||||
| public static extern unsafe string TF_Message(TF_Status s); | public static extern unsafe string TF_Message(TF_Status s); | ||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static unsafe extern IntPtr TF_NewGraph(); | |||||
| public static unsafe extern TF_Graph TF_NewGraph(); | |||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static unsafe extern TF_OperationDescription TF_NewOperation(TF_Graph graph, string opType, string oper_name); | public static unsafe extern TF_OperationDescription TF_NewOperation(TF_Graph graph, string opType, string oper_name); | ||||
| @@ -49,7 +47,7 @@ namespace TensorFlowNET.Core | |||||
| public static unsafe extern TF_Status TF_NewStatus(); | public static unsafe extern TF_Status TF_NewStatus(); | ||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static extern unsafe TF_Tensor TF_NewTensor(TF_DataType dataType, Int64 dims, int num_dims, IntPtr data, size_t len, Deallocator deallocator, IntPtr deallocator_arg); | |||||
| public static extern unsafe TF_Tensor TF_NewTensor(TF_DataType dataType, Int64 dims, int num_dims, IntPtr data, size_t len, tf.Deallocator deallocator, IntPtr deallocator_arg); | |||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static extern unsafe int TF_OperationNumOutputs(TF_Operation oper); | public static extern unsafe int TF_OperationNumOutputs(TF_Operation oper); | ||||
| @@ -4,11 +4,10 @@ using System.Runtime.InteropServices; | |||||
| using System.Text; | using System.Text; | ||||
| using System.Threading; | using System.Threading; | ||||
| using Tensorflow; | using Tensorflow; | ||||
| using tf = TensorFlowNET.Core.tf; | |||||
| using node_def_pb2 = Tensorflow; | using node_def_pb2 = Tensorflow; | ||||
| using Google.Protobuf; | using Google.Protobuf; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public static class ops | public static class ops | ||||
| { | { | ||||
| @@ -4,7 +4,7 @@ using System.IO; | |||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | using Tensorflow; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public static class gen_array_ops | public static class gen_array_ops | ||||
| { | { | ||||
| @@ -20,7 +20,8 @@ namespace TensorFlowNET.Core | |||||
| _attrs["dtype"] = _op.get_attr("dtype"); | _attrs["dtype"] = _op.get_attr("dtype"); | ||||
| _attrs["shape"] = _op.get_attr("shape"); | _attrs["shape"] = _op.get_attr("shape"); | ||||
| return null; | |||||
| var tensor = new Tensor(_op, 0, dtype); | |||||
| return tensor; | |||||
| } | } | ||||
| private static OpDefLibrary _InitOpDefLibrary() | private static OpDefLibrary _InitOpDefLibrary() | ||||
| @@ -0,0 +1,15 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| { | |||||
| public static class gen_math_ops | |||||
| { | |||||
| public static Tensor add(Tensor a, Tensor b, string name = "") | |||||
| { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -2,10 +2,9 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using Tensorflow; | |||||
| using tensor_pb2 = Tensorflow; | using tensor_pb2 = Tensorflow; | ||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public static class tensor_util | public static class tensor_util | ||||
| { | { | ||||
| @@ -13,7 +12,7 @@ namespace TensorFlowNET.Core | |||||
| { | { | ||||
| NDArray nparray; | NDArray nparray; | ||||
| TensorProto tensor_proto = null; | TensorProto tensor_proto = null; | ||||
| TensorShape tensor_shape = new TensorShape(); | |||||
| TensorShape tensor_shape = new TensorShape(0); | |||||
| switch (values) | switch (values) | ||||
| { | { | ||||
| @@ -4,10 +4,9 @@ using System.Runtime.InteropServices; | |||||
| using System.Text; | using System.Text; | ||||
| using TF_DataType = Tensorflow.DataType; | using TF_DataType = Tensorflow.DataType; | ||||
| using attr_value_pb2 = Tensorflow; | using attr_value_pb2 = Tensorflow; | ||||
| using Tensorflow; | |||||
| using TensorFlowNET.Core.Eager; | |||||
| using Tensorflow.Eager; | |||||
| namespace TensorFlowNET.Core | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public static class tf | public static class tf | ||||
| { | { | ||||
| @@ -26,12 +25,14 @@ namespace TensorFlowNET.Core | |||||
| public static unsafe Tensor placeholder(DataType dtype, TensorShape shape = null) | public static unsafe Tensor placeholder(DataType dtype, TensorShape shape = null) | ||||
| { | { | ||||
| var g = ops.get_default_graph(); | |||||
| /*var g = ops.get_default_graph(); | |||||
| var op = new Operation(g, "Placeholder", "feed"); | var op = new Operation(g, "Placeholder", "feed"); | ||||
| var tensor = new Tensor(op, 0, dtype); | var tensor = new Tensor(op, 0, dtype); | ||||
| //return gen_array_ops.placeholder(dtype, shape); | |||||
| return tensor; | |||||
| return tensor;*/ | |||||
| return gen_array_ops.placeholder(dtype, shape); | |||||
| } | } | ||||
| public static unsafe Tensor constant(object value) | public static unsafe Tensor constant(object value) | ||||
| @@ -1,7 +1,7 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using tf = TensorFlowNET.Core.tf; | |||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.Examples | namespace TensorFlowNET.Examples | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using TensorFlowNET.Core; | |||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.UnitTest | namespace TensorFlowNET.UnitTest | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using TensorFlowNET.Core; | |||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.UnitTest | namespace TensorFlowNET.UnitTest | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | using System.Text; | ||||
| using TensorFlowNET.Core; | |||||
| using Tensorflow; | |||||
| namespace TensorFlowNET.UnitTest | namespace TensorFlowNET.UnitTest | ||||
| { | { | ||||
| @@ -13,7 +13,7 @@ namespace TensorFlowNET.UnitTest | |||||
| public void GetVersion() | public void GetVersion() | ||||
| { | { | ||||
| var ver = tf.VERSION; | var ver = tf.VERSION; | ||||
| Assert.IsTrue(ver.Contains(".")); | |||||
| Assert.IsTrue(ver.StartsWith("1.")); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||