From 67a58b3eac4e1eae2acd2117e2c01c43d98a3c0f Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Mon, 19 Aug 2019 23:10:30 -0500 Subject: [PATCH] change tensorflow to non-static class in order to execute some initialization. --- src/KerasNET.Core/Core.cs | 1 + src/KerasNET.Core/Layers/Dense.cs | 1 + src/KerasNET.Core/Model.cs | 2 +- src/TensorFlowNET.Core/APIs/tf.array.cs | 20 +-- src/TensorFlowNET.Core/APIs/tf.control.cs | 6 +- .../APIs/tf.distributions.cs | 8 +- src/TensorFlowNET.Core/APIs/tf.exp.cs | 4 +- src/TensorFlowNET.Core/APIs/tf.gradients.cs | 8 +- src/TensorFlowNET.Core/APIs/tf.graph.cs | 8 +- src/TensorFlowNET.Core/APIs/tf.init.cs | 16 +-- src/TensorFlowNET.Core/APIs/tf.io.cs | 10 +- src/TensorFlowNET.Core/APIs/tf.layers.cs | 15 ++- src/TensorFlowNET.Core/APIs/tf.linalg.cs | 8 +- src/TensorFlowNET.Core/APIs/tf.loss.cs | 4 +- src/TensorFlowNET.Core/APIs/tf.math.cs | 116 +++++++++--------- src/TensorFlowNET.Core/APIs/tf.nn.cs | 46 +++---- src/TensorFlowNET.Core/APIs/tf.ops.cs | 8 +- src/TensorFlowNET.Core/APIs/tf.random.cs | 8 +- .../APIs/tf.reduce_logsumexp.cs | 4 +- src/TensorFlowNET.Core/APIs/tf.reshape.cs | 6 +- src/TensorFlowNET.Core/APIs/tf.summary.cs | 6 +- src/TensorFlowNET.Core/APIs/tf.tensor.cs | 8 +- src/TensorFlowNET.Core/APIs/tf.tile.cs | 6 +- src/TensorFlowNET.Core/APIs/tf.variable.cs | 8 +- src/TensorFlowNET.Core/Binding.cs | 11 ++ src/TensorFlowNET.Core/Clustering/KMeans.cs | 1 + .../Framework/meta_graph.py.cs | 1 + .../Gradients/array_grad.cs | 1 + src/TensorFlowNET.Core/Gradients/math_grad.cs | 1 + .../Graphs/DefaultGraphStack.cs | 1 + .../Graphs/Graph.Operation.cs | 1 + src/TensorFlowNET.Core/IPyClass.cs | 2 +- .../Keras/Layers/BatchNormalization.cs | 1 + src/TensorFlowNET.Core/Keras/Layers/Dense.cs | 4 +- .../Keras/Layers/Embedding.cs | 2 + src/TensorFlowNET.Core/Keras/Layers/Layer.cs | 1 + .../Keras/Layers/MaxPooling2D.cs | 4 +- .../Keras/Utils/base_layer_utils.cs | 1 + src/TensorFlowNET.Core/Keras/backend.cs | 3 +- src/TensorFlowNET.Core/Keras/tf.keras.cs | 4 +- src/TensorFlowNET.Core/Layers/Layer.cs | 1 + .../Operations/Distributions/normal.py.cs | 1 + .../Operations/NnOps/rnn.cs | 2 +- .../Operations/array_ops.py.cs | 1 + .../Operations/gen_image_ops.py.cs | 1 + src/TensorFlowNET.Core/Python.cs | 13 +- src/TensorFlowNET.Core/Sessions/Session.cs | 2 +- src/TensorFlowNET.Core/Tensors/constant_op.cs | 1 + src/TensorFlowNET.Core/Tensors/tf.constant.cs | 18 +-- src/TensorFlowNET.Core/Train/Optimizer.cs | 1 + src/TensorFlowNET.Core/Train/Saving/Saver.cs | 1 + src/TensorFlowNET.Core/Train/SlotCreator.cs | 1 + src/TensorFlowNET.Core/Train/tf.optimizers.cs | 18 +-- .../Variables/_VariableStore.cs | 1 + src/TensorFlowNET.Core/ops.py.cs | 1 + .../{tf.cs => tensorflow.cs} | 68 ++++++---- .../TensorBenchmark.cs | 1 + .../FunctionApproximation.fs | 2 +- test/TensorFlowNET.Examples/BasicEagerApi.cs | 1 + .../BasicModels/KMeansClustering.cs | 1 + .../BasicModels/LinearRegression.cs | 1 + .../BasicModels/LogisticRegression.cs | 1 + .../BasicModels/NaiveBayesClassifier.cs | 2 +- .../BasicModels/NearestNeighbor.cs | 1 + .../BasicModels/NeuralNetXor.cs | 2 +- .../TensorFlowNET.Examples/BasicOperations.cs | 4 +- test/TensorFlowNET.Examples/HelloWorld.cs | 2 +- .../ImageProcessing/DigitRecognitionCNN.cs | 3 +- .../ImageProcessing/DigitRecognitionNN.cs | 3 +- .../ImageProcessing/DigitRecognitionRNN.cs | 1 + .../ImageProcessing/ImageBackgroundRemoval.cs | 2 +- .../ImageRecognitionInception.cs | 4 +- .../ImageProcessing/InceptionArchGoogLeNet.cs | 4 +- .../ImageProcessing/ObjectDetection.cs | 4 +- .../ImageProcessing/RetrainImageClassifier.cs | 7 +- test/TensorFlowNET.Examples/Keras.cs | 1 + test/TensorFlowNET.Examples/Program.cs | 1 + .../TextProcessing/CnnTextClassification.cs | 1 + .../TextProcessing/NER/LstmCrfNer.cs | 1 + .../TextProcessing/Word2Vec.cs | 1 + .../TextProcessing/cnn_models/CharCnn.cs | 1 + .../TextProcessing/cnn_models/VdCnn.cs | 3 +- .../TextProcessing/cnn_models/WordCnn.cs | 1 + .../Basics/AssignTests.cs | 2 +- .../Basics/NegativeTests.cs | 2 +- test/TensorFlowNET.UnitTest/ConstantTest.cs | 2 +- test/TensorFlowNET.UnitTest/ConsumersTest.cs | 1 + .../ExamplesTests/ExamplesTest.cs | 1 + test/TensorFlowNET.UnitTest/GradientTest.cs | 1 + test/TensorFlowNET.UnitTest/GraphTest.cs | 2 +- test/TensorFlowNET.UnitTest/KerasTests.cs | 1 + test/TensorFlowNET.UnitTest/NameScopeTest.cs | 1 + test/TensorFlowNET.UnitTest/OperationsTest.cs | 1 + .../TensorFlowNET.UnitTest/PlaceholderTest.cs | 2 +- test/TensorFlowNET.UnitTest/PythonTest.cs | 3 +- test/TensorFlowNET.UnitTest/SessionTest.cs | 2 +- test/TensorFlowNET.UnitTest/TensorTest.cs | 1 + test/TensorFlowNET.UnitTest/TrainSaverTest.cs | 1 + test/TensorFlowNET.UnitTest/VariableTest.cs | 3 +- test/TensorFlowNET.UnitTest/VersionTest.cs | 1 + .../control_flow_ops_test/CondTestCases.cs | 2 +- .../WhileContextTestCase.cs | 1 + .../gradients_test/GradientsTest.cs | 2 +- .../nest_test/NestTest.cs | 1 + .../ops_test/ControlDependenciesTest.cs | 1 + .../ops_test/CreateOpFromTfOperationTest.cs | 1 + 106 files changed, 338 insertions(+), 250 deletions(-) create mode 100644 src/TensorFlowNET.Core/Binding.cs rename src/TensorFlowNET.Core/{tf.cs => tensorflow.cs} (52%) diff --git a/src/KerasNET.Core/Core.cs b/src/KerasNET.Core/Core.cs index 4be5a48e..d2e77c0e 100644 --- a/src/KerasNET.Core/Core.cs +++ b/src/KerasNET.Core/Core.cs @@ -1,4 +1,5 @@ using Tensorflow; +using static Tensorflow.Binding; namespace Keras { diff --git a/src/KerasNET.Core/Layers/Dense.cs b/src/KerasNET.Core/Layers/Dense.cs index 8938d05f..893dbc10 100644 --- a/src/KerasNET.Core/Layers/Dense.cs +++ b/src/KerasNET.Core/Layers/Dense.cs @@ -19,6 +19,7 @@ using Tensorflow; using static Keras.Keras; using NumSharp; using Tensorflow.Operations.Activation; +using static Tensorflow.Binding; namespace Keras.Layers { diff --git a/src/KerasNET.Core/Model.cs b/src/KerasNET.Core/Model.cs index d1d05159..034c7f64 100644 --- a/src/KerasNET.Core/Model.cs +++ b/src/KerasNET.Core/Model.cs @@ -19,7 +19,7 @@ using NumSharp; using System; using System.Collections.Generic; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Keras { diff --git a/src/TensorFlowNET.Core/APIs/tf.array.cs b/src/TensorFlowNET.Core/APIs/tf.array.cs index 48f16b2b..06d48555 100644 --- a/src/TensorFlowNET.Core/APIs/tf.array.cs +++ b/src/TensorFlowNET.Core/APIs/tf.array.cs @@ -20,7 +20,7 @@ using System.Linq; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { /// /// Concatenates tensors along one dimension. @@ -29,7 +29,7 @@ namespace Tensorflow /// /// /// A `Tensor` resulting from concatenation of the input tensors. - public static Tensor concat(IList values, int axis, string name = "concat") + public Tensor concat(IList values, int axis, string name = "concat") { if (values.Count == 1) throw new NotImplementedException("tf.concat length is 1"); @@ -48,7 +48,7 @@ namespace Tensorflow /// A `Tensor` with the same data as `input`, but its shape has an additional /// dimension of size 1 added. /// - public static Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1) + public Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1) => array_ops.expand_dims(input, axis, name, dim); /// @@ -58,14 +58,14 @@ namespace Tensorflow /// /// /// - public static Tensor fill(Tensor dims, T value, string name = null) + public Tensor fill(Tensor dims, T value, string name = null) => gen_array_ops.fill(dims, value, name: name); /// /// Return the elements, either from `x` or `y`, depending on the `condition`. /// /// - public static Tensor where(Tensor condition, Tx x, Ty y, string name = null) + public Tensor where(Tensor condition, Tx x, Ty y, string name = null) => array_ops.where(condition, x, y, name); /// @@ -76,10 +76,10 @@ namespace Tensorflow /// /// /// - public static Tensor transpose(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false) + public Tensor transpose(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false) => array_ops.transpose(a, perm, name, conjugate); - public static Tensor squeeze(Tensor input, int[] axis = null, string name = null, int squeeze_dims = -1) + public Tensor squeeze(Tensor input, int[] axis = null, string name = null, int squeeze_dims = -1) => gen_array_ops.squeeze(input, axis, name); /// @@ -89,10 +89,10 @@ namespace Tensorflow /// /// /// - public static Tensor stack(object values, int axis = 0, string name = "stack") + public Tensor stack(object values, int axis = 0, string name = "stack") => array_ops.stack(values, axis, name: name); - public static Tensor one_hot(Tensor indices, int depth, + public Tensor one_hot(Tensor indices, int depth, Tensor on_value = null, Tensor off_value = null, TF_DataType dtype = TF_DataType.DtInvalid, @@ -110,7 +110,7 @@ namespace Tensorflow /// /// A name for the operation (optional). /// A `Tensor`. Has the same type as `input`. - public static Tensor placeholder_with_default(T input, int[] shape, string name = null) + public Tensor placeholder_with_default(T input, int[] shape, string name = null) => gen_array_ops.placeholder_with_default(input, shape, name: name); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.control.cs b/src/TensorFlowNET.Core/APIs/tf.control.cs index d744a141..dcccb6fe 100644 --- a/src/TensorFlowNET.Core/APIs/tf.control.cs +++ b/src/TensorFlowNET.Core/APIs/tf.control.cs @@ -18,9 +18,9 @@ using System; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor while_loop(Func cond, Func body, Tensor[] loop_vars, + public Tensor while_loop(Func cond, Func body, Tensor[] loop_vars, TensorShape shape_invariants = null, int parallel_iterations = 10, bool back_prop = true, @@ -37,7 +37,7 @@ namespace Tensorflow maximum_iterations: maximum_iterations, return_same_structure: return_same_structure); - public static _ControlDependenciesController control_dependencies(Operation[] control_inputs) + public _ControlDependenciesController control_dependencies(Operation[] control_inputs) => ops.control_dependencies(control_inputs); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.distributions.cs b/src/TensorFlowNET.Core/APIs/tf.distributions.cs index dbf2478c..c9ccad91 100644 --- a/src/TensorFlowNET.Core/APIs/tf.distributions.cs +++ b/src/TensorFlowNET.Core/APIs/tf.distributions.cs @@ -16,11 +16,13 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static class distributions + public distributions_internal distributions { get; } = new distributions_internal(); + + public class distributions_internal { - public static Normal Normal(Tensor loc, + public Normal Normal(Tensor loc, Tensor scale, bool validate_args = false, bool allow_nan_stats = true, diff --git a/src/TensorFlowNET.Core/APIs/tf.exp.cs b/src/TensorFlowNET.Core/APIs/tf.exp.cs index 8caeb12e..56ea1898 100644 --- a/src/TensorFlowNET.Core/APIs/tf.exp.cs +++ b/src/TensorFlowNET.Core/APIs/tf.exp.cs @@ -16,9 +16,9 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor exp(Tensor x, + public Tensor exp(Tensor x, string name = null) => gen_math_ops.exp(x, name); } diff --git a/src/TensorFlowNET.Core/APIs/tf.gradients.cs b/src/TensorFlowNET.Core/APIs/tf.gradients.cs index dcdca7a3..b8931b15 100644 --- a/src/TensorFlowNET.Core/APIs/tf.gradients.cs +++ b/src/TensorFlowNET.Core/APIs/tf.gradients.cs @@ -16,9 +16,9 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor[] gradients(Tensor[] ys, + public Tensor[] gradients(Tensor[] ys, Tensor[] xs, Tensor[] grad_ys = null, string name = "gradients", @@ -36,7 +36,7 @@ namespace Tensorflow stop_gradients: stop_gradients); } - public static Tensor[] gradients(Tensor ys, + public Tensor[] gradients(Tensor ys, Tensor[] xs, Tensor[] grad_ys = null, string name = "gradients", @@ -54,7 +54,7 @@ namespace Tensorflow stop_gradients: stop_gradients); } - public static Tensor[] gradients(Tensor ys, + public Tensor[] gradients(Tensor ys, Tensor xs, Tensor[] grad_ys = null, string name = "gradients", diff --git a/src/TensorFlowNET.Core/APIs/tf.graph.cs b/src/TensorFlowNET.Core/APIs/tf.graph.cs index 402ffca1..a60c0413 100644 --- a/src/TensorFlowNET.Core/APIs/tf.graph.cs +++ b/src/TensorFlowNET.Core/APIs/tf.graph.cs @@ -16,15 +16,15 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static graph_util_impl graph_util => new graph_util_impl(); - public static Graph get_default_graph() + public graph_util_impl graph_util => new graph_util_impl(); + public Graph get_default_graph() { return ops.get_default_graph(); } - public static Graph Graph() + public Graph Graph() => new Graph(); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.init.cs b/src/TensorFlowNET.Core/APIs/tf.init.cs index 6809b344..f6fa380c 100644 --- a/src/TensorFlowNET.Core/APIs/tf.init.cs +++ b/src/TensorFlowNET.Core/APIs/tf.init.cs @@ -18,14 +18,14 @@ using Tensorflow.Operations.Initializers; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static IInitializer zeros_initializer => new Zeros(); - public static IInitializer ones_initializer => new Ones(); - public static IInitializer glorot_uniform_initializer => new GlorotUniform(); - public static IInitializer uniform_initializer => new RandomUniform(); + public IInitializer zeros_initializer => new Zeros(); + public IInitializer ones_initializer => new Ones(); + public IInitializer glorot_uniform_initializer => new GlorotUniform(); + public IInitializer uniform_initializer => new RandomUniform(); - public static variable_scope variable_scope(string name, + public variable_scope variable_scope(string name, string default_name = null, Tensor[] values = null, bool? reuse = null, @@ -35,7 +35,7 @@ namespace Tensorflow reuse: reuse, auxiliary_name_scope: auxiliary_name_scope); - public static variable_scope variable_scope(VariableScope scope, + public variable_scope variable_scope(VariableScope scope, string default_name = null, Tensor[] values = null, bool? reuse = null, @@ -45,7 +45,7 @@ namespace Tensorflow reuse: reuse, auxiliary_name_scope: auxiliary_name_scope); - public static IInitializer truncated_normal_initializer(float mean = 0.0f, + public IInitializer truncated_normal_initializer(float mean = 0.0f, float stddev = 1.0f, int? seed = null, TF_DataType dtype = TF_DataType.DtInvalid) => new TruncatedNormal(mean: mean, diff --git a/src/TensorFlowNET.Core/APIs/tf.io.cs b/src/TensorFlowNET.Core/APIs/tf.io.cs index 618b1ea5..5980cf81 100644 --- a/src/TensorFlowNET.Core/APIs/tf.io.cs +++ b/src/TensorFlowNET.Core/APIs/tf.io.cs @@ -19,14 +19,14 @@ using Tensorflow.IO; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static GFile gfile = new GFile(); - public static Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name); + public GFile gfile = new GFile(); + public Tensor read_file(string filename, string name = null) => gen_io_ops.read_file(filename, name); - public static gen_image_ops image => new gen_image_ops(); + public gen_image_ops image => new gen_image_ops(); - public static void import_graph_def(GraphDef graph_def, + public void import_graph_def(GraphDef graph_def, Dictionary input_map = null, string[] return_elements = null, string name = null, diff --git a/src/TensorFlowNET.Core/APIs/tf.layers.cs b/src/TensorFlowNET.Core/APIs/tf.layers.cs index a832adab..53ddcf13 100644 --- a/src/TensorFlowNET.Core/APIs/tf.layers.cs +++ b/src/TensorFlowNET.Core/APIs/tf.layers.cs @@ -16,14 +16,17 @@ using Tensorflow.Keras.Layers; using Tensorflow.Operations.Activation; +using static Tensorflow.Binding; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static class layers + public layers_internal layers { get; } = new layers_internal(); + + public class layers_internal { - public static Tensor conv2d(Tensor inputs, + public Tensor conv2d(Tensor inputs, int filters, int[] kernel_size, int[] strides = null, @@ -80,7 +83,7 @@ namespace Tensorflow /// /// /// - public static Tensor batch_normalization(Tensor inputs, + public Tensor batch_normalization(Tensor inputs, int axis = -1, float momentum = 0.99f, float epsilon = 0.001f, @@ -124,7 +127,7 @@ namespace Tensorflow /// /// /// - public static Tensor max_pooling2d(Tensor inputs, + public Tensor max_pooling2d(Tensor inputs, int[] pool_size, int[] strides, string padding = "valid", @@ -140,7 +143,7 @@ namespace Tensorflow return layer.apply(inputs); } - public static Tensor dense(Tensor inputs, + public Tensor dense(Tensor inputs, int units, IActivation activation = null, bool use_bias = true, diff --git a/src/TensorFlowNET.Core/APIs/tf.linalg.cs b/src/TensorFlowNET.Core/APIs/tf.linalg.cs index 76a6123a..b4141460 100644 --- a/src/TensorFlowNET.Core/APIs/tf.linalg.cs +++ b/src/TensorFlowNET.Core/APIs/tf.linalg.cs @@ -16,15 +16,15 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor diag(Tensor diagonal, string name = null) + public Tensor diag(Tensor diagonal, string name = null) => gen_array_ops.diag(diagonal, name: name); - public static Tensor matmul(Tensor a, Tensor b) + public Tensor matmul(Tensor a, Tensor b) => gen_math_ops.mat_mul(a, b); - public static Tensor batch_matmul(Tensor x, Tensor y) + public Tensor batch_matmul(Tensor x, Tensor y) => gen_math_ops.batch_mat_mul(x, y); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.loss.cs b/src/TensorFlowNET.Core/APIs/tf.loss.cs index 1b1b4445..48ed0150 100644 --- a/src/TensorFlowNET.Core/APIs/tf.loss.cs +++ b/src/TensorFlowNET.Core/APIs/tf.loss.cs @@ -16,8 +16,8 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static LossesImpl losses => new LossesImpl(); + public LossesImpl losses => new LossesImpl(); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.math.cs b/src/TensorFlowNET.Core/APIs/tf.math.cs index c2686812..ddfa71ec 100644 --- a/src/TensorFlowNET.Core/APIs/tf.math.cs +++ b/src/TensorFlowNET.Core/APIs/tf.math.cs @@ -16,9 +16,9 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor abs(Tensor x, string name = null) + public Tensor abs(Tensor x, string name = null) => math_ops.abs(x, name); /// @@ -27,7 +27,7 @@ namespace Tensorflow /// /// /// - public static Tensor acos(Tensor x, string name = null) + public Tensor acos(Tensor x, string name = null) => gen_math_ops.acos(x, name); /// @@ -36,10 +36,10 @@ namespace Tensorflow /// /// /// - public static Tensor asin(Tensor x, string name = null) + public Tensor asin(Tensor x, string name = null) => gen_math_ops.asin(x, name); - public static Tensor add(Tx a, Ty b, string name = null) + public Tensor add(Tx a, Ty b, string name = null) => gen_math_ops.add(a, b, name: name); /// @@ -48,19 +48,19 @@ namespace Tensorflow /// /// /// - public static Tensor atan(Tensor x, string name = null) + public Tensor atan(Tensor x, string name = null) => gen_math_ops.atan(x, name); - public static Tensor arg_max(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) + public Tensor arg_max(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) => gen_math_ops.arg_max(input, dimension, output_type: output_type, name: name); - public static Tensor arg_min(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) + public Tensor arg_min(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) => gen_math_ops.arg_min(input, dimension, output_type: output_type, name: name); - public static Tensor is_finite(Tensor input, string name = null) + public Tensor is_finite(Tensor input, string name = null) => gen_math_ops.is_finite(input, name); - public static Tensor is_nan(Tensor input, string name = null) + public Tensor is_nan(Tensor input, string name = null) => gen_math_ops.is_nan(input, name); /// @@ -69,7 +69,7 @@ namespace Tensorflow /// /// /// - public static Tensor ceil(Tensor x, string name = null) + public Tensor ceil(Tensor x, string name = null) => gen_math_ops.ceil(x, name); /// @@ -78,7 +78,7 @@ namespace Tensorflow /// /// /// - public static Tensor sin(Tensor x, string name = null) + public Tensor sin(Tensor x, string name = null) => gen_math_ops.sin(x, name); /// @@ -87,7 +87,7 @@ namespace Tensorflow /// /// /// - public static Tensor sinh(Tensor x, string name = null) + public Tensor sinh(Tensor x, string name = null) => gen_math_ops.sinh(x, name); /// @@ -96,7 +96,7 @@ namespace Tensorflow /// /// /// - public static Tensor cos(Tensor x, string name = null) + public Tensor cos(Tensor x, string name = null) => gen_math_ops.cos(x, name); /// @@ -105,13 +105,13 @@ namespace Tensorflow /// /// /// - public static Tensor cosh(Tensor x, string name = null) + public Tensor cosh(Tensor x, string name = null) => gen_math_ops.cosh(x, name); - public static Tensor tan(Tensor x, string name = null) + public Tensor tan(Tensor x, string name = null) => gen_math_ops.tan(x, name); - public static Tensor tanh(Tensor x, string name = null) + public Tensor tanh(Tensor x, string name = null) => gen_math_ops.tanh(x, name); /// @@ -120,7 +120,7 @@ namespace Tensorflow /// /// /// - public static Tensor floor(Tensor x, string name = null) + public Tensor floor(Tensor x, string name = null) => gen_math_ops.floor(x, name); /// @@ -132,7 +132,7 @@ namespace Tensorflow /// /// /// - public static Tensor greater(Tx x, Ty y, string name = null) + public Tensor greater(Tx x, Ty y, string name = null) => gen_math_ops.greater(x, y, name); /// @@ -144,7 +144,7 @@ namespace Tensorflow /// /// /// - public static Tensor greater_equal(Tx x, Ty y, string name = null) + public Tensor greater_equal(Tx x, Ty y, string name = null) => gen_math_ops.greater_equal(x, y, name); /// @@ -156,7 +156,7 @@ namespace Tensorflow /// /// /// - public static Tensor less(Tx x, Ty y, string name = null) + public Tensor less(Tx x, Ty y, string name = null) => gen_math_ops.less(x, y, name); /// @@ -165,7 +165,7 @@ namespace Tensorflow /// A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`. /// A name for the operation (optional). /// A `Tensor`. Has the same type as `x`. - public static Tensor lgamma(Tensor x, string name = null) + public Tensor lgamma(Tensor x, string name = null) => gen_math_ops.lgamma(x, name: name); /// @@ -177,7 +177,7 @@ namespace Tensorflow /// /// /// - public static Tensor less_equal(Tx x, Ty y, string name = null) + public Tensor less_equal(Tx x, Ty y, string name = null) => gen_math_ops.less_equal(x, y, name); /// @@ -186,19 +186,19 @@ namespace Tensorflow /// /// /// - public static Tensor log1p(Tensor x, string name = null) + public Tensor log1p(Tensor x, string name = null) => gen_math_ops.log1p(x, name); - public static Tensor logical_and(Tensor x, Tensor y, string name = null) + public Tensor logical_and(Tensor x, Tensor y, string name = null) => gen_math_ops.logical_and(x, y, name); - public static Tensor logical_not(Tensor x, string name = null) + public Tensor logical_not(Tensor x, string name = null) => gen_math_ops.logical_not(x, name); - public static Tensor logical_or(Tensor x, Tensor y, string name = null) + public Tensor logical_or(Tensor x, Tensor y, string name = null) => gen_math_ops.logical_or(x, y, name); - public static Tensor logical_xor(Tensor x, Tensor y, string name = "LogicalXor") + public Tensor logical_xor(Tensor x, Tensor y, string name = "LogicalXor") => gen_math_ops.logical_xor(x, y, name); /// @@ -209,28 +209,28 @@ namespace Tensorflow /// /// /// - public static Tensor _clip_by_value(Tensor t, Tensor clip_value_min, Tensor clip_value_max, string name = null) + public Tensor _clip_by_value(Tensor t, Tensor clip_value_min, Tensor clip_value_max, string name = null) => gen_math_ops._clip_by_value(t, clip_value_min, clip_value_max); - public static Tensor sub(Tensor a, Tensor b) + public Tensor sub(Tensor a, Tensor b) => gen_math_ops.sub(a, b); - public static Tensor divide(Tensor a, Tensor b) + public Tensor divide(Tensor a, Tensor b) => gen_math_ops.real_div(a, b); - public static Tensor sqrt(Tensor a, string name = null) + public Tensor sqrt(Tensor a, string name = null) => gen_math_ops.sqrt(a, name); - public static Tensor sign(Tensor a, string name = null) + public Tensor sign(Tensor a, string name = null) => gen_math_ops.sign(a, name); - public static Tensor subtract(Tensor x, T[] y, string name = null) where T : struct + public Tensor subtract(Tensor x, T[] y, string name = null) where T : struct => gen_math_ops.sub(x, ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y"), name); - public static Tensor log(Tensor x, string name = null) + public Tensor log(Tensor x, string name = null) => gen_math_ops.log(x, name); - public static Tensor equal(Tensor x, Tensor y, string name = null) + public Tensor equal(Tensor x, Tensor y, string name = null) => gen_math_ops.equal(x, y, name); /// @@ -240,7 +240,7 @@ namespace Tensorflow /// /// /// - public static Tensor atan2(Tensor y, Tensor x, string name = null) + public Tensor atan2(Tensor y, Tensor x, string name = null) => gen_math_ops.atan2(y, x, name); /// @@ -253,7 +253,7 @@ namespace Tensorflow /// /// /// - public static Tensor max(Tx input, Ty axis, bool keep_dims = false, string name = null) + public Tensor max(Tx input, Ty axis, bool keep_dims = false, string name = null) => gen_math_ops._max(input, axis, keep_dims: keep_dims, name: name); /// @@ -266,7 +266,7 @@ namespace Tensorflow /// /// /// - public static Tensor min(Tx input, Ty axis, bool keep_dims = false, string name = null) + public Tensor min(Tx input, Ty axis, bool keep_dims = false, string name = null) => gen_math_ops._min(input, axis, keep_dims: keep_dims, name: name); /// @@ -278,7 +278,7 @@ namespace Tensorflow /// /// /// - public static Tensor maximum(T1 x, T2 y, string name = null) + public Tensor maximum(T1 x, T2 y, string name = null) => gen_math_ops.maximum(x, y, name: name); /// @@ -290,13 +290,13 @@ namespace Tensorflow /// /// /// - public static Tensor minimum(T1 x, T2 y, string name = null) + public Tensor minimum(T1 x, T2 y, string name = null) => gen_math_ops.minimum(x, y, name: name); - public static Tensor multiply(Tx x, Ty y) + public Tensor multiply(Tx x, Ty y) => gen_math_ops.mul(x, y); - public static Tensor negative(Tensor x, string name = null) + public Tensor negative(Tensor x, string name = null) => gen_math_ops.neg(x, name); /// @@ -306,13 +306,13 @@ namespace Tensorflow /// /// /// - public static Tensor div(Tensor x, Tensor y, string name = null) + public Tensor div(Tensor x, Tensor y, string name = null) => math_ops.div(x, y, name: name); - public static Tensor divide(Tensor x, T[] y, string name = null) where T : struct + public Tensor divide(Tensor x, T[] y, string name = null) where T : struct => x / ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y"); - public static Tensor pow(T1 x, T2 y) + public Tensor pow(T1 x, T2 y) => gen_math_ops.pow(x, y); /// @@ -321,14 +321,14 @@ namespace Tensorflow /// /// /// - public static Tensor reduce_sum(Tensor input, int? axis = null, int? reduction_indices = null) + public Tensor reduce_sum(Tensor input, int? axis = null, int? reduction_indices = null) { if(!axis.HasValue && reduction_indices.HasValue) return math_ops.reduce_sum(input, reduction_indices.Value); return math_ops.reduce_sum(input); } - public static Tensor reduce_sum(Tensor input, int axis, int? reduction_indices = null) + public Tensor reduce_sum(Tensor input, int axis, int? reduction_indices = null) => math_ops.reduce_sum(input, axis); /// @@ -339,34 +339,34 @@ namespace Tensorflow /// /// /// - public static Tensor reduce_max(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) + public Tensor reduce_max(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) => math_ops.reduce_max(input_tensor, axis, keepdims, name); - public static Tensor reduce_min(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) + public Tensor reduce_min(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) => math_ops.reduce_min(input_tensor, axis, keepdims, name); - public static Tensor sigmoid(T x, string name = null) + public Tensor sigmoid(T x, string name = null) => math_ops.sigmoid(x, name: name); - public static Tensor sum(Tensor input, int axis, bool keep_dims = false, string name = null) + public Tensor sum(Tensor input, int axis, bool keep_dims = false, string name = null) => gen_math_ops._sum(input, axis, keep_dims: keep_dims, name: name); - public static Tensor reduce_mean(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null, int? reduction_indices = null) + public Tensor reduce_mean(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null, int? reduction_indices = null) => math_ops.reduce_mean(input_tensor, axis: axis, keepdims: keepdims, name: name, reduction_indices: reduction_indices); - public static Tensor round(Tensor x, string name = null) + public Tensor round(Tensor x, string name = null) => gen_math_ops.round(x, name: name); - public static Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, string name = null) + public Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, string name = null) => math_ops.cast(x, dtype, name); - public static Tensor cumsum(Tensor x, int axis = 0, bool exclusive = false, bool reverse = false, string name = null) + public Tensor cumsum(Tensor x, int axis = 0, bool exclusive = false, bool reverse = false, string name = null) => math_ops.cumsum(x, axis: axis, exclusive: exclusive, reverse: reverse, name: name); - public static Tensor argmax(Tensor input, int axis = -1, string name = null, int? dimension = null, TF_DataType output_type = TF_DataType.TF_INT64) + public Tensor argmax(Tensor input, int axis = -1, string name = null, int? dimension = null, TF_DataType output_type = TF_DataType.TF_INT64) => gen_math_ops.arg_max(input, axis, name: name, output_type: output_type); - public static Tensor square(Tensor x, string name = null) + public Tensor square(Tensor x, string name = null) => gen_math_ops.square(x, name: name); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.nn.cs b/src/TensorFlowNET.Core/APIs/tf.nn.cs index 8a631c05..1c88d1e9 100644 --- a/src/TensorFlowNET.Core/APIs/tf.nn.cs +++ b/src/TensorFlowNET.Core/APIs/tf.nn.cs @@ -20,11 +20,13 @@ using static Tensorflow.Python; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static class nn + public nn_internal nn { get; } = new nn_internal(); + + public class nn_internal { - public static Tensor conv2d(Tensor input, RefVariable filter, int[] strides, string padding, bool use_cudnn_on_gpu = true, + public Tensor conv2d(Tensor input, RefVariable filter, int[] strides, string padding, bool use_cudnn_on_gpu = true, string data_format= "NHWC", int[] dilations= null, string name = null) { var parameters = new Conv2dParams @@ -54,7 +56,7 @@ namespace Tensorflow /// /// A scalar `Tensor` with the same type as `x`. /// A Tensor of the same shape of `x`. - public static Tensor dropout(Tensor x, Tensor keep_prob = null, Tensor noise_shape = null, int? seed = null, string name = null, + public Tensor dropout(Tensor x, Tensor keep_prob = null, Tensor noise_shape = null, int? seed = null, string name = null, float? rate = null) { Tensor keep = null; @@ -74,17 +76,17 @@ namespace Tensorflow /// /// /// A pair (outputs, state) - public static (Tensor, Tensor) dynamic_rnn(RNNCell cell, Tensor inputs, + public (Tensor, Tensor) dynamic_rnn(RNNCell cell, Tensor inputs, Tensor sequence_length = null, TF_DataType dtype = TF_DataType.DtInvalid, int? parallel_iterations = null, bool swap_memory = false, bool time_major = false) => rnn.dynamic_rnn(cell, inputs, sequence_length: sequence_length, dtype: dtype, parallel_iterations: parallel_iterations, swap_memory: swap_memory, time_major: time_major); - public static Tensor elu(Tensor features, string name = null) + public Tensor elu(Tensor features, string name = null) => gen_nn_ops.elu(features, name: name); - public static (Tensor, Tensor) moments(Tensor x, + public (Tensor, Tensor) moments(Tensor x, int[] axes, string name = null, bool keep_dims = false) => nn_impl.moments(x, @@ -92,7 +94,7 @@ namespace Tensorflow name: name, keep_dims: keep_dims); - public static Tensor embedding_lookup(RefVariable @params, + public Tensor embedding_lookup(RefVariable @params, Tensor ids, string partition_strategy = "mod", string name = null) => embedding_ops._embedding_lookup_and_transform(@params, @@ -100,7 +102,7 @@ namespace Tensorflow partition_strategy: partition_strategy, name: name); - public static Tensor embedding_lookup(Tensor @params, + public Tensor embedding_lookup(Tensor @params, Tensor ids, string partition_strategy = "mod", string name = null) => embedding_ops._embedding_lookup_and_transform(new Tensor[] { @params }, @@ -108,11 +110,11 @@ namespace Tensorflow partition_strategy: partition_strategy, name: name); - public static IActivation relu() => new relu(); + public IActivation relu() => new relu(); - public static Tensor relu(Tensor features, string name = null) => gen_nn_ops.relu(features, name); + public Tensor relu(Tensor features, string name = null) => gen_nn_ops.relu(features, name); - public static Tensor[] fused_batch_norm(Tensor x, + public Tensor[] fused_batch_norm(Tensor x, RefVariable scale, RefVariable offset, Tensor mean = null, @@ -126,18 +128,18 @@ namespace Tensorflow is_training: is_training, name: name); - public static IPoolFunction max_pool_fn => new MaxPoolFunction(); + public IPoolFunction max_pool_fn => new MaxPoolFunction(); - public static Tensor max_pool(Tensor value, int[] ksize, int[] strides, string padding, string data_format = "NHWC", string name = null) + public Tensor max_pool(Tensor value, int[] ksize, int[] strides, string padding, string data_format = "NHWC", string name = null) => nn_ops.max_pool(value, ksize, strides, padding, data_format: data_format, name: name); - public static Tensor in_top_k(Tensor predictions, Tensor targets, int k, string name = "InTopK") + public Tensor in_top_k(Tensor predictions, Tensor targets, int k, string name = "InTopK") => gen_ops.in_top_k(predictions, targets, k, name); - public static Tensor[] top_k(Tensor input, int k = 1, bool sorted = true, string name = null) + public Tensor[] top_k(Tensor input, int k = 1, bool sorted = true, string name = null) => gen_nn_ops.top_kv2(input, k: k, sorted: sorted, name: name); - public static Tensor bias_add(Tensor value, RefVariable bias, string data_format = null, string name = null) + public Tensor bias_add(Tensor value, RefVariable bias, string data_format = null, string name = null) { return Python.tf_with(ops.name_scope(name, "BiasAdd", new { value, bias }), scope => { @@ -146,9 +148,9 @@ namespace Tensorflow }); } - public static rnn_cell_impl rnn_cell => new rnn_cell_impl(); + public rnn_cell_impl rnn_cell => new rnn_cell_impl(); - public static Tensor softmax(Tensor logits, int axis = -1, string name = null) + public Tensor softmax(Tensor logits, int axis = -1, string name = null) => gen_nn_ops.softmax(logits, name); /// @@ -158,7 +160,7 @@ namespace Tensorflow /// /// /// - public static Tensor sparse_softmax_cross_entropy_with_logits(Tensor labels = null, + public Tensor sparse_softmax_cross_entropy_with_logits(Tensor labels = null, Tensor logits = null, string name = null) => nn_ops.sparse_softmax_cross_entropy_with_logits(labels: labels, logits: logits, name: name); @@ -170,7 +172,7 @@ namespace Tensorflow /// /// /// - public static Tensor softmax_cross_entropy_with_logits(Tensor labels, Tensor logits, int dim = -1, string name = null) + public Tensor softmax_cross_entropy_with_logits(Tensor labels, Tensor logits, int dim = -1, string name = null) { tf_with(ops.name_scope(name, "softmax_cross_entropy_with_logits_sg", new { logits, labels }), scope => { @@ -181,7 +183,7 @@ namespace Tensorflow return softmax_cross_entropy_with_logits_v2(labels, logits, axis: dim, name: name); } - public static Tensor softmax_cross_entropy_with_logits_v2(Tensor labels, Tensor logits, int axis = -1, string name = null) + public Tensor softmax_cross_entropy_with_logits_v2(Tensor labels, Tensor logits, int axis = -1, string name = null) => nn_ops.softmax_cross_entropy_with_logits_v2_helper(labels, logits, axis: axis, name: name); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.ops.cs b/src/TensorFlowNET.Core/APIs/tf.ops.cs index dbd1b246..ba678327 100644 --- a/src/TensorFlowNET.Core/APIs/tf.ops.cs +++ b/src/TensorFlowNET.Core/APIs/tf.ops.cs @@ -16,12 +16,12 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor assign(Tensor @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null) + public Tensor assign(Tensor @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null) => state_ops.assign(@ref, value, validate_shape, use_locking, name); - public static object get_collection(string key, string scope = "") + public object get_collection(string key, string scope = "") => get_default_graph().get_collection(key, scope: scope); /// @@ -31,7 +31,7 @@ namespace Tensorflow /// The default name to use if the name argument is None. /// The list of Tensor arguments that are passed to the op function. /// The scope name. - public static ops.NameScope name_scope(string name, string default_name = "", object values = null) + public ops.NameScope name_scope(string name, string default_name = "", object values = null) => new ops.NameScope(name, default_name, values); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.random.cs b/src/TensorFlowNET.Core/APIs/tf.random.cs index 338542d0..ae115872 100644 --- a/src/TensorFlowNET.Core/APIs/tf.random.cs +++ b/src/TensorFlowNET.Core/APIs/tf.random.cs @@ -16,7 +16,7 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { /// /// Outputs random values from a normal distribution. @@ -28,21 +28,21 @@ namespace Tensorflow /// /// /// - public static Tensor random_normal(int[] shape, + public Tensor random_normal(int[] shape, float mean = 0.0f, float stddev = 1.0f, TF_DataType dtype = TF_DataType.TF_FLOAT, int? seed = null, string name = null) => random_ops.random_normal(shape, mean, stddev, dtype, seed, name); - public static Tensor random_uniform(int[] shape, + public Tensor random_uniform(int[] shape, float minval = 0, float maxval = 1, TF_DataType dtype = TF_DataType.TF_FLOAT, int? seed = null, string name = null) => random_ops.random_uniform(shape, minval, maxval, dtype, seed, name); - public static Tensor truncated_normal(int[] shape, + public Tensor truncated_normal(int[] shape, float mean = 0.0f, float stddev = 1.0f, TF_DataType dtype = TF_DataType.TF_FLOAT, diff --git a/src/TensorFlowNET.Core/APIs/tf.reduce_logsumexp.cs b/src/TensorFlowNET.Core/APIs/tf.reduce_logsumexp.cs index d97dd34b..325f0633 100644 --- a/src/TensorFlowNET.Core/APIs/tf.reduce_logsumexp.cs +++ b/src/TensorFlowNET.Core/APIs/tf.reduce_logsumexp.cs @@ -16,9 +16,9 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor reduce_logsumexp(Tensor input_tensor, + public Tensor reduce_logsumexp(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) => math_ops.reduce_logsumexp(input_tensor, axis, keepdims, name); diff --git a/src/TensorFlowNET.Core/APIs/tf.reshape.cs b/src/TensorFlowNET.Core/APIs/tf.reshape.cs index fac5271e..78a00432 100644 --- a/src/TensorFlowNET.Core/APIs/tf.reshape.cs +++ b/src/TensorFlowNET.Core/APIs/tf.reshape.cs @@ -16,13 +16,13 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor reshape(Tensor tensor, + public Tensor reshape(Tensor tensor, Tensor shape, string name = null) => gen_array_ops.reshape(tensor, shape, name); - public static Tensor reshape(Tensor tensor, + public Tensor reshape(Tensor tensor, int[] shape, string name = null) => gen_array_ops.reshape(tensor, shape, name); } diff --git a/src/TensorFlowNET.Core/APIs/tf.summary.cs b/src/TensorFlowNET.Core/APIs/tf.summary.cs index a5d52df4..a2611739 100644 --- a/src/TensorFlowNET.Core/APIs/tf.summary.cs +++ b/src/TensorFlowNET.Core/APIs/tf.summary.cs @@ -16,11 +16,11 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Summaries.Summary summary = new Summaries.Summary(); + public Summaries.Summary summary = new Summaries.Summary(); - public static Tensor scalar(string name, Tensor tensor) + public Tensor scalar(string name, Tensor tensor) => summary.scalar(name, tensor); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.tensor.cs b/src/TensorFlowNET.Core/APIs/tf.tensor.cs index 24d3ddf1..b553095e 100644 --- a/src/TensorFlowNET.Core/APIs/tf.tensor.cs +++ b/src/TensorFlowNET.Core/APIs/tf.tensor.cs @@ -16,12 +16,12 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor convert_to_tensor(object value, + public Tensor convert_to_tensor(object value, string name = null) => ops.convert_to_tensor(value, name: name); - public static Tensor strided_slice(Tensor input, Tensor begin, Tensor end, Tensor strides = null, + public Tensor strided_slice(Tensor input, Tensor begin, Tensor end, Tensor strides = null, int begin_mask = 0, int end_mask = 0, int ellipsis_mask = 0, @@ -38,7 +38,7 @@ namespace Tensorflow shrink_axis_mask: shrink_axis_mask, name: name); - public static Tensor strided_slice(Tensor input, T[] begin, T[] end, T[] strides = null, + public Tensor strided_slice(Tensor input, T[] begin, T[] end, T[] strides = null, int begin_mask = 0, int end_mask = 0, int ellipsis_mask = 0, diff --git a/src/TensorFlowNET.Core/APIs/tf.tile.cs b/src/TensorFlowNET.Core/APIs/tf.tile.cs index 3001166b..21017a17 100644 --- a/src/TensorFlowNET.Core/APIs/tf.tile.cs +++ b/src/TensorFlowNET.Core/APIs/tf.tile.cs @@ -18,12 +18,12 @@ using NumSharp; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static Tensor tile(Tensor input, + public Tensor tile(Tensor input, Tensor multiples, string name = null) => gen_array_ops.tile(input, multiples, name); - public static Tensor tile(NDArray input, + public Tensor tile(NDArray input, int[] multiples, string name = null) => gen_array_ops.tile(input, multiples, name); diff --git a/src/TensorFlowNET.Core/APIs/tf.variable.cs b/src/TensorFlowNET.Core/APIs/tf.variable.cs index 6512fd92..e855535a 100644 --- a/src/TensorFlowNET.Core/APIs/tf.variable.cs +++ b/src/TensorFlowNET.Core/APIs/tf.variable.cs @@ -18,21 +18,21 @@ using System.Collections.Generic; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static VariableV1[] global_variables(string scope = null) + public VariableV1[] global_variables(string scope = null) { return (ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES, scope) as List) .ToArray(); } - public static Operation global_variables_initializer() + public Operation global_variables_initializer() { var g = variables.global_variables(); return variables.variables_initializer(g.ToArray()); } - public static RefVariable get_variable(string name, + public RefVariable get_variable(string name, TensorShape shape = null, TF_DataType dtype = TF_DataType.DtInvalid, object initializer = null, // IInitializer or Tensor diff --git a/src/TensorFlowNET.Core/Binding.cs b/src/TensorFlowNET.Core/Binding.cs new file mode 100644 index 00000000..8f2de0eb --- /dev/null +++ b/src/TensorFlowNET.Core/Binding.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tensorflow +{ + public static class Binding + { + public static tensorflow tf { get; } = Python.New(); + } +} diff --git a/src/TensorFlowNET.Core/Clustering/KMeans.cs b/src/TensorFlowNET.Core/Clustering/KMeans.cs index 1ef948a0..e3f2ab2a 100644 --- a/src/TensorFlowNET.Core/Clustering/KMeans.cs +++ b/src/TensorFlowNET.Core/Clustering/KMeans.cs @@ -15,6 +15,7 @@ ******************************************************************************/ using System; +using static Tensorflow.Binding; namespace Tensorflow.Clustering { diff --git a/src/TensorFlowNET.Core/Framework/meta_graph.py.cs b/src/TensorFlowNET.Core/Framework/meta_graph.py.cs index 4a10ba1e..db9dba38 100644 --- a/src/TensorFlowNET.Core/Framework/meta_graph.py.cs +++ b/src/TensorFlowNET.Core/Framework/meta_graph.py.cs @@ -22,6 +22,7 @@ using System.Linq; using Tensorflow.Operations; using static Tensorflow.CollectionDef; using static Tensorflow.MetaGraphDef.Types; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Gradients/array_grad.cs b/src/TensorFlowNET.Core/Gradients/array_grad.cs index 9fe2aeed..a6eede7c 100644 --- a/src/TensorFlowNET.Core/Gradients/array_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/array_grad.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Linq; using Tensorflow.Framework; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow.Gradients { diff --git a/src/TensorFlowNET.Core/Gradients/math_grad.cs b/src/TensorFlowNET.Core/Gradients/math_grad.cs index a5ac79ba..a7fdcba5 100644 --- a/src/TensorFlowNET.Core/Gradients/math_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/math_grad.cs @@ -18,6 +18,7 @@ using System; using System.Linq; using Tensorflow.Operations; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow.Gradients { diff --git a/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs b/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs index f066676d..6c9f6b18 100644 --- a/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs +++ b/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using System.Linq; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs b/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs index 1030922b..436afcc9 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/IPyClass.cs b/src/TensorFlowNET.Core/IPyClass.cs index 4cde6ce5..47190a7d 100644 --- a/src/TensorFlowNET.Core/IPyClass.cs +++ b/src/TensorFlowNET.Core/IPyClass.cs @@ -22,7 +22,7 @@ namespace Tensorflow /// Called when the instance is created. /// /// - void __init__(IPyClass self, dynamic args); + void __init__(IPyClass self); void __enter__(IPyClass self); diff --git a/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs b/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs index 156cc8c9..51230aab 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs @@ -17,6 +17,7 @@ using System; using System.Linq; using Tensorflow.Keras.Utils; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Layers { diff --git a/src/TensorFlowNET.Core/Keras/Layers/Dense.cs b/src/TensorFlowNET.Core/Keras/Layers/Dense.cs index e2cea7f3..adfae5d1 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Dense.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Dense.cs @@ -19,7 +19,7 @@ using System.Collections.Generic; using System.Linq; using Tensorflow.Keras.Engine; using Tensorflow.Operations.Activation; -using static Tensorflow.tf; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Layers { @@ -86,7 +86,7 @@ namespace Tensorflow.Keras.Layers } if (use_bias) - outputs = nn.bias_add(outputs, bias); + outputs = tf.nn.bias_add(outputs, bias); if (activation != null) return activation.Activate(outputs); diff --git a/src/TensorFlowNET.Core/Keras/Layers/Embedding.cs b/src/TensorFlowNET.Core/Keras/Layers/Embedding.cs index 299f158d..37f15baf 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Embedding.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Embedding.cs @@ -14,6 +14,8 @@ limitations under the License. ******************************************************************************/ +using static Tensorflow.Binding; + namespace Tensorflow.Keras.Layers { public class Embedding : Layer diff --git a/src/TensorFlowNET.Core/Keras/Layers/Layer.cs b/src/TensorFlowNET.Core/Keras/Layers/Layer.cs index d96c1f14..24bda725 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Layer.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Layer.cs @@ -21,6 +21,7 @@ using Tensorflow.Keras.Engine; using Tensorflow.Keras.Utils; using Tensorflow.Train; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Layers { diff --git a/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs b/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs index 77e78e1c..27234078 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs @@ -1,4 +1,4 @@ -using static Tensorflow.tf; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Layers { @@ -9,7 +9,7 @@ namespace Tensorflow.Keras.Layers int[] strides, string padding = "valid", string data_format = null, - string name = null) : base(nn.max_pool_fn, pool_size, + string name = null) : base(tf.nn.max_pool_fn, pool_size, strides, padding: padding, data_format: data_format, diff --git a/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs b/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs index a34d9ad0..d4feebc2 100644 --- a/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs +++ b/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using System.Linq; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Utils { diff --git a/src/TensorFlowNET.Core/Keras/backend.cs b/src/TensorFlowNET.Core/Keras/backend.cs index 3760df04..1161f07b 100644 --- a/src/TensorFlowNET.Core/Keras/backend.cs +++ b/src/TensorFlowNET.Core/Keras/backend.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow.Keras { @@ -28,7 +29,7 @@ namespace Tensorflow.Keras //Func py_any = any; //Func> py_slice = slice; - public static Session _SESSION = Tensorflow.tf.defaultSession; + public static Session _SESSION = tf.defaultSession; public static Graph _GRAPH = null; public static Dictionary _GRAPH_LEARNING_PHASES; //Dictionary> PER_GRAPH_LAYER_NAME_UIDS; diff --git a/src/TensorFlowNET.Core/Keras/tf.keras.cs b/src/TensorFlowNET.Core/Keras/tf.keras.cs index bf439809..dee173f8 100644 --- a/src/TensorFlowNET.Core/Keras/tf.keras.cs +++ b/src/TensorFlowNET.Core/Keras/tf.keras.cs @@ -2,9 +2,9 @@ namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static class keras + public class keras { public static Initializers initializers => new Initializers(); } diff --git a/src/TensorFlowNET.Core/Layers/Layer.cs b/src/TensorFlowNET.Core/Layers/Layer.cs index 961952a6..5bbafe14 100644 --- a/src/TensorFlowNET.Core/Layers/Layer.cs +++ b/src/TensorFlowNET.Core/Layers/Layer.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow.Layers { diff --git a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs index f4f4b4bf..c3c5d4d4 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs index b4955dec..32d92179 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs @@ -19,7 +19,7 @@ using System.Collections.Generic; using System.Linq; using static Tensorflow.Python; using Tensorflow.Util; -using NumSharp; +using static Tensorflow.Binding; namespace Tensorflow.Operations { diff --git a/src/TensorFlowNET.Core/Operations/array_ops.py.cs b/src/TensorFlowNET.Core/Operations/array_ops.py.cs index f563a61f..fc02ba73 100644 --- a/src/TensorFlowNET.Core/Operations/array_ops.py.cs +++ b/src/TensorFlowNET.Core/Operations/array_ops.py.cs @@ -18,6 +18,7 @@ using NumSharp; using System; using System.Collections.Generic; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Operations/gen_image_ops.py.cs b/src/TensorFlowNET.Core/Operations/gen_image_ops.py.cs index dc7188a8..507a1d3e 100644 --- a/src/TensorFlowNET.Core/Operations/gen_image_ops.py.cs +++ b/src/TensorFlowNET.Core/Operations/gen_image_ops.py.cs @@ -16,6 +16,7 @@ using System; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Python.cs b/src/TensorFlowNET.Core/Python.cs index 0122aafb..b5240cf4 100644 --- a/src/TensorFlowNET.Core/Python.cs +++ b/src/TensorFlowNET.Core/Python.cs @@ -66,12 +66,10 @@ namespace Tensorflow return Enumerable.Range(start, end - start); } - public static T New(object args) where T : IPyClass + public static T New() where T : IPyClass, new() { - var instance = Activator.CreateInstance(); - - instance.__init__(instance, args); - + var instance = new T(); + instance.__init__(instance); return instance; } @@ -347,9 +345,4 @@ namespace Tensorflow void __exit__(); } - - public class PyObject where T : IPyClass - { - public T Instance { get; set; } - } } diff --git a/src/TensorFlowNET.Core/Sessions/Session.cs b/src/TensorFlowNET.Core/Sessions/Session.cs index 6b238ae7..79c469a2 100644 --- a/src/TensorFlowNET.Core/Sessions/Session.cs +++ b/src/TensorFlowNET.Core/Sessions/Session.cs @@ -15,7 +15,7 @@ ******************************************************************************/ using System; -using System.Runtime.InteropServices; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/constant_op.cs b/src/TensorFlowNET.Core/Tensors/constant_op.cs index 2e4f64eb..92eda9ba 100644 --- a/src/TensorFlowNET.Core/Tensors/constant_op.cs +++ b/src/TensorFlowNET.Core/Tensors/constant_op.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/tf.constant.cs b/src/TensorFlowNET.Core/Tensors/tf.constant.cs index ddb450e2..a6516740 100644 --- a/src/TensorFlowNET.Core/Tensors/tf.constant.cs +++ b/src/TensorFlowNET.Core/Tensors/tf.constant.cs @@ -18,11 +18,11 @@ using NumSharp; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { // public static Tensor constant(NDArray nd, string name = "Const") => constant_op.constant(nd, name: name); - public static Tensor constant(object value, + public Tensor constant(object value, TF_DataType dtype = TF_DataType.DtInvalid, int[] shape = null, string name = "Const", @@ -33,30 +33,30 @@ namespace Tensorflow verify_shape: verify_shape, allow_broadcast: false); - public static Tensor constant(string value, + public Tensor constant(string value, string name = "Const") => constant_op._constant_impl(value, - tf.@string, + @string, new int[] { 1 }, name, verify_shape: false, allow_broadcast: false); - public static Tensor constant(float value, + public Tensor constant(float value, int shape, string name = "Const") => constant_op._constant_impl(value, - tf.float32, + float32, new int[] { shape }, name, verify_shape: false, allow_broadcast: false); - public static Tensor zeros(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) + public Tensor zeros(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) => array_ops.zeros(shape, dtype, name); - public static Tensor ones(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) + public Tensor ones(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) => array_ops.ones(shape, dtype, name); - public static Tensor size(Tensor input, + public Tensor size(Tensor input, string name = null, TF_DataType out_type = TF_DataType.TF_INT32) => array_ops.size(input, name, diff --git a/src/TensorFlowNET.Core/Train/Optimizer.cs b/src/TensorFlowNET.Core/Train/Optimizer.cs index e945b120..56041826 100644 --- a/src/TensorFlowNET.Core/Train/Optimizer.cs +++ b/src/TensorFlowNET.Core/Train/Optimizer.cs @@ -20,6 +20,7 @@ using System.Linq; using Tensorflow.Framework; using Tensorflow.Train; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Train/Saving/Saver.cs b/src/TensorFlowNET.Core/Train/Saving/Saver.cs index 781c6461..aea585c5 100644 --- a/src/TensorFlowNET.Core/Train/Saving/Saver.cs +++ b/src/TensorFlowNET.Core/Train/Saving/Saver.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Train/SlotCreator.cs b/src/TensorFlowNET.Core/Train/SlotCreator.cs index 57582355..0872d8a6 100644 --- a/src/TensorFlowNET.Core/Train/SlotCreator.cs +++ b/src/TensorFlowNET.Core/Train/SlotCreator.cs @@ -17,6 +17,7 @@ using System; using Tensorflow.Operations.Initializers; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow.Train { diff --git a/src/TensorFlowNET.Core/Train/tf.optimizers.cs b/src/TensorFlowNET.Core/Train/tf.optimizers.cs index 5dee2060..0c801f90 100644 --- a/src/TensorFlowNET.Core/Train/tf.optimizers.cs +++ b/src/TensorFlowNET.Core/Train/tf.optimizers.cs @@ -19,28 +19,30 @@ using Tensorflow.Train; namespace Tensorflow { - public static partial class tf + public partial class tensorflow { - public static class train + public train_internal train { get; } = new train_internal(); + + public class train_internal { - public static Optimizer GradientDescentOptimizer(float learning_rate) + public Optimizer GradientDescentOptimizer(float learning_rate) => new GradientDescentOptimizer(learning_rate); - public static Optimizer AdamOptimizer(float learning_rate, string name = "Adam") + public Optimizer AdamOptimizer(float learning_rate, string name = "Adam") => new AdamOptimizer(learning_rate, name: name); - public static Saver Saver(VariableV1[] var_list = null) => new Saver(var_list: var_list); + public Saver Saver(VariableV1[] var_list = null) => new Saver(var_list: var_list); - public static string write_graph(Graph graph, string logdir, string name, bool as_text = true) + public string write_graph(Graph graph, string logdir, string name, bool as_text = true) => graph_io.write_graph(graph, logdir, name, as_text); - public static Saver import_meta_graph(string meta_graph_or_file, + public Saver import_meta_graph(string meta_graph_or_file, bool clear_devices = false, string import_scope = "") => saver._import_meta_graph_with_return_elements(meta_graph_or_file, clear_devices, import_scope).Item1; - public static (MetaGraphDef, Dictionary) export_meta_graph(string filename = "", + public (MetaGraphDef, Dictionary) export_meta_graph(string filename = "", bool as_text = false, bool clear_devices = false, bool clear_extraneous_savers = false, diff --git a/src/TensorFlowNET.Core/Variables/_VariableStore.cs b/src/TensorFlowNET.Core/Variables/_VariableStore.cs index 06719dc1..8957568e 100644 --- a/src/TensorFlowNET.Core/Variables/_VariableStore.cs +++ b/src/TensorFlowNET.Core/Variables/_VariableStore.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/ops.py.cs b/src/TensorFlowNET.Core/ops.py.cs index 979e132e..97cc6861 100644 --- a/src/TensorFlowNET.Core/ops.py.cs +++ b/src/TensorFlowNET.Core/ops.py.cs @@ -21,6 +21,7 @@ using Google.Protobuf; using System.Linq; using NumSharp; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/tf.cs b/src/TensorFlowNET.Core/tensorflow.cs similarity index 52% rename from src/TensorFlowNET.Core/tf.cs rename to src/TensorFlowNET.Core/tensorflow.cs index b10f41b0..c3857e66 100644 --- a/src/TensorFlowNET.Core/tf.cs +++ b/src/TensorFlowNET.Core/tensorflow.cs @@ -18,25 +18,25 @@ using Tensorflow.Eager; namespace Tensorflow { - public static partial class tf + public partial class tensorflow : IPyClass { - public static TF_DataType @byte = TF_DataType.TF_UINT8; - public static TF_DataType @sbyte = TF_DataType.TF_INT8; - public static TF_DataType int16 = TF_DataType.TF_INT16; - public static TF_DataType int32 = TF_DataType.TF_INT32; - public static TF_DataType int64 = TF_DataType.TF_INT64; - public static TF_DataType float16 = TF_DataType.TF_HALF; - public static TF_DataType float32 = TF_DataType.TF_FLOAT; - public static TF_DataType float64 = TF_DataType.TF_DOUBLE; - public static TF_DataType @bool = TF_DataType.TF_BOOL; - public static TF_DataType chars = TF_DataType.TF_STRING; - public static TF_DataType @string = TF_DataType.TF_STRING; - - public static Context context = new Context(new ContextOptions(), new Status()); - - public static Session defaultSession; - - public static RefVariable Variable(T data, + public TF_DataType @byte = TF_DataType.TF_UINT8; + public TF_DataType @sbyte = TF_DataType.TF_INT8; + public TF_DataType int16 = TF_DataType.TF_INT16; + public TF_DataType int32 = TF_DataType.TF_INT32; + public TF_DataType int64 = TF_DataType.TF_INT64; + public TF_DataType float16 = TF_DataType.TF_HALF; + public TF_DataType float32 = TF_DataType.TF_FLOAT; + public TF_DataType float64 = TF_DataType.TF_DOUBLE; + public TF_DataType @bool = TF_DataType.TF_BOOL; + public TF_DataType chars = TF_DataType.TF_STRING; + public TF_DataType @string = TF_DataType.TF_STRING; + + public Context context = new Context(new ContextOptions(), new Status()); + + public Session defaultSession; + + public RefVariable Variable(T data, bool trainable = true, bool validate_shape = true, string name = null, @@ -49,33 +49,53 @@ namespace Tensorflow dtype: dtype); } - public static unsafe Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = null) + public unsafe Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = null) { return gen_array_ops.placeholder(dtype, shape, name); } - public static void enable_eager_execution() + public void enable_eager_execution() { // contex = new Context(); context.default_execution_mode = Context.EAGER_MODE; } - public static string VERSION => c_api.StringPiece(c_api.TF_Version()); + public string VERSION => c_api.StringPiece(c_api.TF_Version()); - public static Session Session() + public Session Session() { defaultSession = new Session(); return defaultSession; } - public static Session Session(Graph graph) + public Session Session(Graph graph) { return new Session(graph); } - public static Session Session(SessionOptions opts) + public Session Session(SessionOptions opts) { return new Session(null, opts); } + + public void __init__(IPyClass self) + { + + } + + public void __enter__(IPyClass self) + { + + } + + public void __exit__(IPyClass self) + { + + } + + public void __del__(IPyClass self) + { + + } } } diff --git a/src/TensorFlowNet.Benchmarks/TensorBenchmark.cs b/src/TensorFlowNet.Benchmarks/TensorBenchmark.cs index 3a0eeb65..d9386b99 100644 --- a/src/TensorFlowNet.Benchmarks/TensorBenchmark.cs +++ b/src/TensorFlowNet.Benchmarks/TensorBenchmark.cs @@ -2,6 +2,7 @@ using BenchmarkDotNet.Attributes; using NumSharp; using Tensorflow; +using static Tensorflow.Binding; namespace TensorFlowBenchmark { diff --git a/test/TensorFlowNET.Examples.FSharp/FunctionApproximation.fs b/test/TensorFlowNET.Examples.FSharp/FunctionApproximation.fs index 38c650a3..4b9d3fbb 100644 --- a/test/TensorFlowNET.Examples.FSharp/FunctionApproximation.fs +++ b/test/TensorFlowNET.Examples.FSharp/FunctionApproximation.fs @@ -6,7 +6,6 @@ open NumSharp open Tensorflow open System - let run()= let N_points = 75 // Number of points for constructing function @@ -40,6 +39,7 @@ let run()= let n_hidden_layer_1 = 25 // Hidden layer 1 let n_hidden_layer_2 = 25 // Hidden layer 2 + let tf = Python.New() let x = tf.placeholder(tf.float64, new TensorShape(N_points,n_input)) let y = tf.placeholder(tf.float64, new TensorShape(n_output)) diff --git a/test/TensorFlowNET.Examples/BasicEagerApi.cs b/test/TensorFlowNET.Examples/BasicEagerApi.cs index ab2d1f8a..ac6e6e82 100644 --- a/test/TensorFlowNET.Examples/BasicEagerApi.cs +++ b/test/TensorFlowNET.Examples/BasicEagerApi.cs @@ -1,5 +1,6 @@ using System; using Tensorflow; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs b/test/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs index 25ce085e..b1aea250 100644 --- a/test/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs +++ b/test/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs @@ -20,6 +20,7 @@ using System.Diagnostics; using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/BasicModels/LinearRegression.cs b/test/TensorFlowNET.Examples/BasicModels/LinearRegression.cs index 0098404d..8d74ec27 100644 --- a/test/TensorFlowNET.Examples/BasicModels/LinearRegression.cs +++ b/test/TensorFlowNET.Examples/BasicModels/LinearRegression.cs @@ -18,6 +18,7 @@ using NumSharp; using System; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs b/test/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs index 1b34b961..af7b6668 100644 --- a/test/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs +++ b/test/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs @@ -21,6 +21,7 @@ using System.IO; using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs b/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs index 70809cc7..fde1653d 100644 --- a/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs +++ b/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; using Tensorflow; using NumSharp; -using static Tensorflow.Python; +using static Tensorflow.Binding; using System.IO; using TensorFlowNET.Examples.Utility; diff --git a/test/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs b/test/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs index eb96d275..3890f500 100644 --- a/test/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs +++ b/test/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs @@ -19,6 +19,7 @@ using System; using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/BasicModels/NeuralNetXor.cs b/test/TensorFlowNET.Examples/BasicModels/NeuralNetXor.cs index 8b158012..e9bcf0cb 100644 --- a/test/TensorFlowNET.Examples/BasicModels/NeuralNetXor.cs +++ b/test/TensorFlowNET.Examples/BasicModels/NeuralNetXor.cs @@ -18,7 +18,7 @@ using System; using NumSharp; using Tensorflow; using TensorFlowNET.Examples.Utility; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/BasicOperations.cs b/test/TensorFlowNET.Examples/BasicOperations.cs index c7314abe..ff382009 100644 --- a/test/TensorFlowNET.Examples/BasicOperations.cs +++ b/test/TensorFlowNET.Examples/BasicOperations.cs @@ -1,7 +1,7 @@ using NumSharp; using System; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -95,7 +95,7 @@ namespace TensorFlowNET.Examples Console.WriteLine(result.ToString()); // ==> [[ 12.]] }; - // `BatchMatMul` is actually embedded into the `MatMul` operation on the tensorflow.dll side. Every time we ask + // `BatchMatMul` is actually embedded into the `MatMul` operation on the tf.dll side. Every time we ask // for a multiplication between matrices with rank > 2, the first rank - 2 dimensions are checked to be consistent // across the two matrices and a common matrix multiplication is done on the residual 2 dimensions. // diff --git a/test/TensorFlowNET.Examples/HelloWorld.cs b/test/TensorFlowNET.Examples/HelloWorld.cs index 52e47e3d..28c4b093 100644 --- a/test/TensorFlowNET.Examples/HelloWorld.cs +++ b/test/TensorFlowNET.Examples/HelloWorld.cs @@ -1,6 +1,6 @@ using System; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs index 9c22b149..42d2d4d1 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs @@ -20,6 +20,7 @@ using System.Diagnostics; using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -27,7 +28,7 @@ namespace TensorFlowNET.Examples /// Convolutional Neural Network classifier for Hand Written Digits /// CNN architecture with two convolutional layers, followed by two fully-connected layers at the end. /// Use Stochastic Gradient Descent (SGD) optimizer. - /// http://www.easy-tensorflow.com/tf-tutorials/convolutional-neural-nets-cnns/cnn1 + /// http://www.easy-tf.com/tf-tutorials/convolutional-neural-nets-cnns/cnn1 /// public class DigitRecognitionCNN : IExample { diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs index 9125c286..0c6e2cd8 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs @@ -19,6 +19,7 @@ using System; using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -26,7 +27,7 @@ namespace TensorFlowNET.Examples /// Neural Network classifier for Hand Written Digits /// Sample Neural Network architecture with two layers implemented for classifying MNIST digits. /// Use Stochastic Gradient Descent (SGD) optimizer. - /// http://www.easy-tensorflow.com/tf-tutorials/neural-networks + /// http://www.easy-tf.com/tf-tutorials/neural-networks /// public class DigitRecognitionNN : IExample { diff --git a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs index cecd85ff..a5606de1 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs @@ -19,6 +19,7 @@ using System; using Tensorflow; using Tensorflow.Hub; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs b/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs index 8eed577b..1bc9781f 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs @@ -2,7 +2,7 @@ using System.IO; using Tensorflow; using TensorFlowNET.Examples.Utility; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/ImageProcessing/ImageRecognitionInception.cs b/test/TensorFlowNET.Examples/ImageProcessing/ImageRecognitionInception.cs index 85e0357a..0414d68d 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/ImageRecognitionInception.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/ImageRecognitionInception.cs @@ -6,7 +6,7 @@ using System.IO; using Console = Colorful.Console; using Tensorflow; using System.Drawing; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -89,7 +89,7 @@ namespace TensorFlowNET.Examples Directory.CreateDirectory(dir); // get model file - string url = "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip"; + string url = "https://storage.googleapis.com/download.tf.org/models/inception5h.zip"; Utility.Web.Download(url, dir, "inception5h.zip"); diff --git a/test/TensorFlowNET.Examples/ImageProcessing/InceptionArchGoogLeNet.cs b/test/TensorFlowNET.Examples/ImageProcessing/InceptionArchGoogLeNet.cs index 93fa9c2c..704067fc 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/InceptionArchGoogLeNet.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/InceptionArchGoogLeNet.cs @@ -3,7 +3,7 @@ using System; using System.IO; using System.Linq; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -93,7 +93,7 @@ namespace TensorFlowNET.Examples Directory.CreateDirectory(dir); // get model file - string url = "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz"; + string url = "https://storage.googleapis.com/download.tf.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz"; Utility.Web.Download(url, dir, $"{pbFile}.tar.gz"); diff --git a/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection.cs b/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection.cs index f5c967a7..50093f3c 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection.cs @@ -22,7 +22,7 @@ using TensorFlowNET.Examples.Utility; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -84,7 +84,7 @@ namespace TensorFlowNET.Examples public void PrepareData() { // get model file - string url = "http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz"; + string url = "http://download.tf.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz"; Web.Download(url, modelDir, "ssd_mobilenet_v1_coco.tar.gz"); Compress.ExtractTGZ(Path.Join(modelDir, "ssd_mobilenet_v1_coco.tar.gz"), "./"); diff --git a/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs b/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs index 92442d17..7e0bbdc6 100644 --- a/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs +++ b/test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs @@ -24,6 +24,7 @@ using System.Linq; using Tensorflow; using TensorFlowNET.Examples.Utility; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { @@ -32,7 +33,7 @@ namespace TensorFlowNET.Examples /// and simply train a new classification layer on top. Transfer learning is a technique that shortcuts much of this /// by taking a piece of a model that has already been trained on a related task and reusing it in a new model. /// - /// https://www.tensorflow.org/hub/tutorials/image_retraining + /// https://www.tf.org/hub/tutorials/image_retraining /// public class RetrainImageClassifier : IExample { @@ -167,7 +168,7 @@ namespace TensorFlowNET.Examples /// weights, and then sets up all the gradients for the backward pass. /// /// The set up for the softmax and fully-connected layers is based on: - /// https://www.tensorflow.org/tutorials/mnist/beginners/index.html + /// https://www.tf.org/tutorials/mnist/beginners/index.html /// /// /// @@ -508,7 +509,7 @@ namespace TensorFlowNET.Examples { // get a set of images to teach the network about the new classes string fileName = "flower_photos.tgz"; - string url = $"http://download.tensorflow.org/example_images/{fileName}"; + string url = $"http://download.tf.org/example_images/{fileName}"; Web.Download(url, data_dir, fileName); Compress.ExtractTGZ(Path.Join(data_dir, fileName), data_dir); diff --git a/test/TensorFlowNET.Examples/Keras.cs b/test/TensorFlowNET.Examples/Keras.cs index 3bf46c00..aa17e9b2 100644 --- a/test/TensorFlowNET.Examples/Keras.cs +++ b/test/TensorFlowNET.Examples/Keras.cs @@ -4,6 +4,7 @@ using Tensorflow; using Keras.Layers; using NumSharp; using Keras; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/Program.cs b/test/TensorFlowNET.Examples/Program.cs index 0a4c6721..8679a730 100644 --- a/test/TensorFlowNET.Examples/Program.cs +++ b/test/TensorFlowNET.Examples/Program.cs @@ -22,6 +22,7 @@ using System.Linq; using System.Reflection; using Tensorflow; using Console = Colorful.Console; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/TextProcessing/CnnTextClassification.cs b/test/TensorFlowNET.Examples/TextProcessing/CnnTextClassification.cs index d781bccd..55e2516a 100644 --- a/test/TensorFlowNET.Examples/TextProcessing/CnnTextClassification.cs +++ b/test/TensorFlowNET.Examples/TextProcessing/CnnTextClassification.cs @@ -25,6 +25,7 @@ using Tensorflow.Sessions; using TensorFlowNET.Examples.Text; using TensorFlowNET.Examples.Utility; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/TextProcessing/NER/LstmCrfNer.cs b/test/TensorFlowNET.Examples/TextProcessing/NER/LstmCrfNer.cs index db5f230f..2e18a680 100644 --- a/test/TensorFlowNET.Examples/TextProcessing/NER/LstmCrfNer.cs +++ b/test/TensorFlowNET.Examples/TextProcessing/NER/LstmCrfNer.cs @@ -7,6 +7,7 @@ using Tensorflow; using Tensorflow.Estimator; using TensorFlowNET.Examples.Utility; using static Tensorflow.Python; +using static Tensorflow.Binding; using static TensorFlowNET.Examples.DataHelpers; namespace TensorFlowNET.Examples.Text.NER diff --git a/test/TensorFlowNET.Examples/TextProcessing/Word2Vec.cs b/test/TensorFlowNET.Examples/TextProcessing/Word2Vec.cs index 33f50aad..b4da37a9 100644 --- a/test/TensorFlowNET.Examples/TextProcessing/Word2Vec.cs +++ b/test/TensorFlowNET.Examples/TextProcessing/Word2Vec.cs @@ -6,6 +6,7 @@ using System.Linq; using Tensorflow; using TensorFlowNET.Examples.Utility; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples { diff --git a/test/TensorFlowNET.Examples/TextProcessing/cnn_models/CharCnn.cs b/test/TensorFlowNET.Examples/TextProcessing/cnn_models/CharCnn.cs index 75308b8c..1cbddf84 100644 --- a/test/TensorFlowNET.Examples/TextProcessing/cnn_models/CharCnn.cs +++ b/test/TensorFlowNET.Examples/TextProcessing/cnn_models/CharCnn.cs @@ -1,5 +1,6 @@ using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples.Text { diff --git a/test/TensorFlowNET.Examples/TextProcessing/cnn_models/VdCnn.cs b/test/TensorFlowNET.Examples/TextProcessing/cnn_models/VdCnn.cs index 8087a2b2..0f6c74fd 100644 --- a/test/TensorFlowNET.Examples/TextProcessing/cnn_models/VdCnn.cs +++ b/test/TensorFlowNET.Examples/TextProcessing/cnn_models/VdCnn.cs @@ -2,6 +2,7 @@ using System.Linq; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples.Text { @@ -32,7 +33,7 @@ namespace TensorFlowNET.Examples.Text num_filters = new int[] { 64, 64, 128, 256, 512 }; num_blocks = new int[] { 2, 2, 2, 2 }; learning_rate = 0.001f; - cnn_initializer = tf.keras.initializers.he_normal(); + cnn_initializer = tensorflow.keras.initializers.he_normal(); fc_initializer = tf.truncated_normal_initializer(stddev: 0.05f); x = tf.placeholder(tf.int32, new TensorShape(-1, document_max_len), name: "x"); diff --git a/test/TensorFlowNET.Examples/TextProcessing/cnn_models/WordCnn.cs b/test/TensorFlowNET.Examples/TextProcessing/cnn_models/WordCnn.cs index 3448ac83..057322d4 100644 --- a/test/TensorFlowNET.Examples/TextProcessing/cnn_models/WordCnn.cs +++ b/test/TensorFlowNET.Examples/TextProcessing/cnn_models/WordCnn.cs @@ -17,6 +17,7 @@ using System.Collections.Generic; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.Examples.Text { diff --git a/test/TensorFlowNET.UnitTest/Basics/AssignTests.cs b/test/TensorFlowNET.UnitTest/Basics/AssignTests.cs index 9b2b6f3a..3cb85de7 100644 --- a/test/TensorFlowNET.UnitTest/Basics/AssignTests.cs +++ b/test/TensorFlowNET.UnitTest/Basics/AssignTests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.Basics { diff --git a/test/TensorFlowNET.UnitTest/Basics/NegativeTests.cs b/test/TensorFlowNET.UnitTest/Basics/NegativeTests.cs index e953eb8e..600b2731 100644 --- a/test/TensorFlowNET.UnitTest/Basics/NegativeTests.cs +++ b/test/TensorFlowNET.UnitTest/Basics/NegativeTests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.Basics { diff --git a/test/TensorFlowNET.UnitTest/ConstantTest.cs b/test/TensorFlowNET.UnitTest/ConstantTest.cs index 0fbd1883..c1d4c9e5 100644 --- a/test/TensorFlowNET.UnitTest/ConstantTest.cs +++ b/test/TensorFlowNET.UnitTest/ConstantTest.cs @@ -4,7 +4,7 @@ using System; using System.Linq; using System.Runtime.InteropServices; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/ConsumersTest.cs b/test/TensorFlowNET.UnitTest/ConsumersTest.cs index a310fbc9..8ffc7113 100644 --- a/test/TensorFlowNET.UnitTest/ConsumersTest.cs +++ b/test/TensorFlowNET.UnitTest/ConsumersTest.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs b/test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs index 7bcec065..c980692c 100644 --- a/test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs +++ b/test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; using TensorFlowNET.Examples; +using static Tensorflow.Binding; namespace TensorFlowNET.ExamplesTests { diff --git a/test/TensorFlowNET.UnitTest/GradientTest.cs b/test/TensorFlowNET.UnitTest/GradientTest.cs index 6a073471..63bea584 100644 --- a/test/TensorFlowNET.UnitTest/GradientTest.cs +++ b/test/TensorFlowNET.UnitTest/GradientTest.cs @@ -3,6 +3,7 @@ using NumSharp; using System.Linq; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/GraphTest.cs b/test/TensorFlowNET.UnitTest/GraphTest.cs index 31abd561..f5431e01 100644 --- a/test/TensorFlowNET.UnitTest/GraphTest.cs +++ b/test/TensorFlowNET.UnitTest/GraphTest.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using Tensorflow; using Buffer = Tensorflow.Buffer; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/KerasTests.cs b/test/TensorFlowNET.UnitTest/KerasTests.cs index f60b3c61..dfbe3860 100644 --- a/test/TensorFlowNET.UnitTest/KerasTests.cs +++ b/test/TensorFlowNET.UnitTest/KerasTests.cs @@ -2,6 +2,7 @@ using Keras.Layers; using NumSharp; using Microsoft.VisualStudio.TestTools.UnitTesting; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/NameScopeTest.cs b/test/TensorFlowNET.UnitTest/NameScopeTest.cs index 9a2b4346..b6f1ecf6 100644 --- a/test/TensorFlowNET.UnitTest/NameScopeTest.cs +++ b/test/TensorFlowNET.UnitTest/NameScopeTest.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/OperationsTest.cs b/test/TensorFlowNET.UnitTest/OperationsTest.cs index d1db80f1..4c6ae3d0 100644 --- a/test/TensorFlowNET.UnitTest/OperationsTest.cs +++ b/test/TensorFlowNET.UnitTest/OperationsTest.cs @@ -5,6 +5,7 @@ using System.Linq; using NumSharp; using Tensorflow; using Buffer = Tensorflow.Buffer; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/PlaceholderTest.cs b/test/TensorFlowNET.UnitTest/PlaceholderTest.cs index c8ca0dab..14b16c23 100644 --- a/test/TensorFlowNET.UnitTest/PlaceholderTest.cs +++ b/test/TensorFlowNET.UnitTest/PlaceholderTest.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/PythonTest.cs b/test/TensorFlowNET.UnitTest/PythonTest.cs index 12dbd0c3..bb6ac673 100644 --- a/test/TensorFlowNET.UnitTest/PythonTest.cs +++ b/test/TensorFlowNET.UnitTest/PythonTest.cs @@ -5,8 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json.Linq; using NumSharp; using Tensorflow; -using Tensorflow.Util; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/SessionTest.cs b/test/TensorFlowNET.UnitTest/SessionTest.cs index 51620b19..9c8485ec 100644 --- a/test/TensorFlowNET.UnitTest/SessionTest.cs +++ b/test/TensorFlowNET.UnitTest/SessionTest.cs @@ -3,7 +3,7 @@ using NumSharp; using System; using System.Collections.Generic; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/TensorTest.cs b/test/TensorFlowNET.UnitTest/TensorTest.cs index 6666443c..2fc8fa02 100644 --- a/test/TensorFlowNET.UnitTest/TensorTest.cs +++ b/test/TensorFlowNET.UnitTest/TensorTest.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Threading; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/TrainSaverTest.cs b/test/TensorFlowNET.UnitTest/TrainSaverTest.cs index 625ca874..0aaa18c4 100644 --- a/test/TensorFlowNET.UnitTest/TrainSaverTest.cs +++ b/test/TensorFlowNET.UnitTest/TrainSaverTest.cs @@ -2,6 +2,7 @@ using System; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/VariableTest.cs b/test/TensorFlowNET.UnitTest/VariableTest.cs index fc4078c1..15cc053a 100644 --- a/test/TensorFlowNET.UnitTest/VariableTest.cs +++ b/test/TensorFlowNET.UnitTest/VariableTest.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { @@ -28,7 +29,7 @@ namespace TensorFlowNET.UnitTest } /// - /// https://www.tensorflow.org/api_docs/python/tf/variable_scope + /// https://www.tf.org/api_docs/python/tf/variable_scope /// how to create a new variable /// [TestMethod] diff --git a/test/TensorFlowNET.UnitTest/VersionTest.cs b/test/TensorFlowNET.UnitTest/VersionTest.cs index f687efa6..cabcdd25 100644 --- a/test/TensorFlowNET.UnitTest/VersionTest.cs +++ b/test/TensorFlowNET.UnitTest/VersionTest.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest { diff --git a/test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs b/test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs index 94686049..eea640ac 100644 --- a/test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs +++ b/test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.control_flow_ops_test { diff --git a/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs b/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs index 31109f0a..2bbc47c5 100644 --- a/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs +++ b/test/TensorFlowNET.UnitTest/control_flow_ops_test/WhileContextTestCase.cs @@ -2,6 +2,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.control_flow_ops_test { diff --git a/test/TensorFlowNET.UnitTest/gradients_test/GradientsTest.cs b/test/TensorFlowNET.UnitTest/gradients_test/GradientsTest.cs index 82306d9c..ecd69977 100644 --- a/test/TensorFlowNET.UnitTest/gradients_test/GradientsTest.cs +++ b/test/TensorFlowNET.UnitTest/gradients_test/GradientsTest.cs @@ -4,7 +4,7 @@ using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using NumSharp; using Tensorflow; -using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.gradients_test { diff --git a/test/TensorFlowNET.UnitTest/nest_test/NestTest.cs b/test/TensorFlowNET.UnitTest/nest_test/NestTest.cs index e7a3592c..8f924015 100644 --- a/test/TensorFlowNET.UnitTest/nest_test/NestTest.cs +++ b/test/TensorFlowNET.UnitTest/nest_test/NestTest.cs @@ -7,6 +7,7 @@ using NumSharp; using Tensorflow; using Tensorflow.Util; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.nest_test { diff --git a/test/TensorFlowNET.UnitTest/ops_test/ControlDependenciesTest.cs b/test/TensorFlowNET.UnitTest/ops_test/ControlDependenciesTest.cs index 8c8a89dd..67effad4 100644 --- a/test/TensorFlowNET.UnitTest/ops_test/ControlDependenciesTest.cs +++ b/test/TensorFlowNET.UnitTest/ops_test/ControlDependenciesTest.cs @@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; using Tensorflow.Eager; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.ops_test { diff --git a/test/TensorFlowNET.UnitTest/ops_test/CreateOpFromTfOperationTest.cs b/test/TensorFlowNET.UnitTest/ops_test/CreateOpFromTfOperationTest.cs index dcaeaf11..a5cbf88f 100644 --- a/test/TensorFlowNET.UnitTest/ops_test/CreateOpFromTfOperationTest.cs +++ b/test/TensorFlowNET.UnitTest/ops_test/CreateOpFromTfOperationTest.cs @@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Tensorflow; using Tensorflow.Operations; using static Tensorflow.Python; +using static Tensorflow.Binding; namespace TensorFlowNET.UnitTest.ops_test {