Browse Source

change tensorflow to non-static class in order to execute some initialization.

tags/v0.12
Oceania2018 6 years ago
parent
commit
67a58b3eac
100 changed files with 332 additions and 248 deletions
  1. +1
    -0
      src/KerasNET.Core/Core.cs
  2. +1
    -0
      src/KerasNET.Core/Layers/Dense.cs
  3. +1
    -1
      src/KerasNET.Core/Model.cs
  4. +10
    -10
      src/TensorFlowNET.Core/APIs/tf.array.cs
  5. +3
    -3
      src/TensorFlowNET.Core/APIs/tf.control.cs
  6. +5
    -3
      src/TensorFlowNET.Core/APIs/tf.distributions.cs
  7. +2
    -2
      src/TensorFlowNET.Core/APIs/tf.exp.cs
  8. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.gradients.cs
  9. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.graph.cs
  10. +8
    -8
      src/TensorFlowNET.Core/APIs/tf.init.cs
  11. +5
    -5
      src/TensorFlowNET.Core/APIs/tf.io.cs
  12. +9
    -6
      src/TensorFlowNET.Core/APIs/tf.layers.cs
  13. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.linalg.cs
  14. +2
    -2
      src/TensorFlowNET.Core/APIs/tf.loss.cs
  15. +58
    -58
      src/TensorFlowNET.Core/APIs/tf.math.cs
  16. +24
    -22
      src/TensorFlowNET.Core/APIs/tf.nn.cs
  17. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.ops.cs
  18. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.random.cs
  19. +2
    -2
      src/TensorFlowNET.Core/APIs/tf.reduce_logsumexp.cs
  20. +3
    -3
      src/TensorFlowNET.Core/APIs/tf.reshape.cs
  21. +3
    -3
      src/TensorFlowNET.Core/APIs/tf.summary.cs
  22. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.tensor.cs
  23. +3
    -3
      src/TensorFlowNET.Core/APIs/tf.tile.cs
  24. +4
    -4
      src/TensorFlowNET.Core/APIs/tf.variable.cs
  25. +11
    -0
      src/TensorFlowNET.Core/Binding.cs
  26. +1
    -0
      src/TensorFlowNET.Core/Clustering/KMeans.cs
  27. +1
    -0
      src/TensorFlowNET.Core/Framework/meta_graph.py.cs
  28. +1
    -0
      src/TensorFlowNET.Core/Gradients/array_grad.cs
  29. +1
    -0
      src/TensorFlowNET.Core/Gradients/math_grad.cs
  30. +1
    -0
      src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs
  31. +1
    -0
      src/TensorFlowNET.Core/Graphs/Graph.Operation.cs
  32. +1
    -1
      src/TensorFlowNET.Core/IPyClass.cs
  33. +1
    -0
      src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs
  34. +2
    -2
      src/TensorFlowNET.Core/Keras/Layers/Dense.cs
  35. +2
    -0
      src/TensorFlowNET.Core/Keras/Layers/Embedding.cs
  36. +1
    -0
      src/TensorFlowNET.Core/Keras/Layers/Layer.cs
  37. +2
    -2
      src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs
  38. +1
    -0
      src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs
  39. +2
    -1
      src/TensorFlowNET.Core/Keras/backend.cs
  40. +2
    -2
      src/TensorFlowNET.Core/Keras/tf.keras.cs
  41. +1
    -0
      src/TensorFlowNET.Core/Layers/Layer.cs
  42. +1
    -0
      src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs
  43. +1
    -1
      src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
  44. +1
    -0
      src/TensorFlowNET.Core/Operations/array_ops.py.cs
  45. +1
    -0
      src/TensorFlowNET.Core/Operations/gen_image_ops.py.cs
  46. +3
    -10
      src/TensorFlowNET.Core/Python.cs
  47. +1
    -1
      src/TensorFlowNET.Core/Sessions/Session.cs
  48. +1
    -0
      src/TensorFlowNET.Core/Tensors/constant_op.cs
  49. +9
    -9
      src/TensorFlowNET.Core/Tensors/tf.constant.cs
  50. +1
    -0
      src/TensorFlowNET.Core/Train/Optimizer.cs
  51. +1
    -0
      src/TensorFlowNET.Core/Train/Saving/Saver.cs
  52. +1
    -0
      src/TensorFlowNET.Core/Train/SlotCreator.cs
  53. +10
    -8
      src/TensorFlowNET.Core/Train/tf.optimizers.cs
  54. +1
    -0
      src/TensorFlowNET.Core/Variables/_VariableStore.cs
  55. +1
    -0
      src/TensorFlowNET.Core/ops.py.cs
  56. +44
    -24
      src/TensorFlowNET.Core/tensorflow.cs
  57. +1
    -0
      src/TensorFlowNet.Benchmarks/TensorBenchmark.cs
  58. +1
    -1
      test/TensorFlowNET.Examples.FSharp/FunctionApproximation.fs
  59. +1
    -0
      test/TensorFlowNET.Examples/BasicEagerApi.cs
  60. +1
    -0
      test/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs
  61. +1
    -0
      test/TensorFlowNET.Examples/BasicModels/LinearRegression.cs
  62. +1
    -0
      test/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs
  63. +1
    -1
      test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs
  64. +1
    -0
      test/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs
  65. +1
    -1
      test/TensorFlowNET.Examples/BasicModels/NeuralNetXor.cs
  66. +2
    -2
      test/TensorFlowNET.Examples/BasicOperations.cs
  67. +1
    -1
      test/TensorFlowNET.Examples/HelloWorld.cs
  68. +2
    -1
      test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs
  69. +2
    -1
      test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs
  70. +1
    -0
      test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs
  71. +1
    -1
      test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs
  72. +2
    -2
      test/TensorFlowNET.Examples/ImageProcessing/ImageRecognitionInception.cs
  73. +2
    -2
      test/TensorFlowNET.Examples/ImageProcessing/InceptionArchGoogLeNet.cs
  74. +2
    -2
      test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection.cs
  75. +4
    -3
      test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs
  76. +1
    -0
      test/TensorFlowNET.Examples/Keras.cs
  77. +1
    -0
      test/TensorFlowNET.Examples/Program.cs
  78. +1
    -0
      test/TensorFlowNET.Examples/TextProcessing/CnnTextClassification.cs
  79. +1
    -0
      test/TensorFlowNET.Examples/TextProcessing/NER/LstmCrfNer.cs
  80. +1
    -0
      test/TensorFlowNET.Examples/TextProcessing/Word2Vec.cs
  81. +1
    -0
      test/TensorFlowNET.Examples/TextProcessing/cnn_models/CharCnn.cs
  82. +2
    -1
      test/TensorFlowNET.Examples/TextProcessing/cnn_models/VdCnn.cs
  83. +1
    -0
      test/TensorFlowNET.Examples/TextProcessing/cnn_models/WordCnn.cs
  84. +1
    -1
      test/TensorFlowNET.UnitTest/Basics/AssignTests.cs
  85. +1
    -1
      test/TensorFlowNET.UnitTest/Basics/NegativeTests.cs
  86. +1
    -1
      test/TensorFlowNET.UnitTest/ConstantTest.cs
  87. +1
    -0
      test/TensorFlowNET.UnitTest/ConsumersTest.cs
  88. +1
    -0
      test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs
  89. +1
    -0
      test/TensorFlowNET.UnitTest/GradientTest.cs
  90. +1
    -1
      test/TensorFlowNET.UnitTest/GraphTest.cs
  91. +1
    -0
      test/TensorFlowNET.UnitTest/KerasTests.cs
  92. +1
    -0
      test/TensorFlowNET.UnitTest/NameScopeTest.cs
  93. +1
    -0
      test/TensorFlowNET.UnitTest/OperationsTest.cs
  94. +1
    -1
      test/TensorFlowNET.UnitTest/PlaceholderTest.cs
  95. +1
    -2
      test/TensorFlowNET.UnitTest/PythonTest.cs
  96. +1
    -1
      test/TensorFlowNET.UnitTest/SessionTest.cs
  97. +1
    -0
      test/TensorFlowNET.UnitTest/TensorTest.cs
  98. +1
    -0
      test/TensorFlowNET.UnitTest/TrainSaverTest.cs
  99. +2
    -1
      test/TensorFlowNET.UnitTest/VariableTest.cs
  100. +1
    -0
      test/TensorFlowNET.UnitTest/VersionTest.cs

+ 1
- 0
src/KerasNET.Core/Core.cs View File

@@ -1,4 +1,5 @@
using Tensorflow; using Tensorflow;
using static Tensorflow.Binding;


namespace Keras namespace Keras
{ {


+ 1
- 0
src/KerasNET.Core/Layers/Dense.cs View File

@@ -19,6 +19,7 @@ using Tensorflow;
using static Keras.Keras; using static Keras.Keras;
using NumSharp; using NumSharp;
using Tensorflow.Operations.Activation; using Tensorflow.Operations.Activation;
using static Tensorflow.Binding;


namespace Keras.Layers namespace Keras.Layers
{ {


+ 1
- 1
src/KerasNET.Core/Model.cs View File

@@ -19,7 +19,7 @@ using NumSharp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Keras namespace Keras
{ {


+ 10
- 10
src/TensorFlowNET.Core/APIs/tf.array.cs View File

@@ -20,7 +20,7 @@ using System.Linq;


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
/// <summary> /// <summary>
/// Concatenates tensors along one dimension. /// Concatenates tensors along one dimension.
@@ -29,7 +29,7 @@ namespace Tensorflow
/// <param name="axis"></param> /// <param name="axis"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns>A `Tensor` resulting from concatenation of the input tensors.</returns> /// <returns>A `Tensor` resulting from concatenation of the input tensors.</returns>
public static Tensor concat(IList<Tensor> values, int axis, string name = "concat")
public Tensor concat(IList<Tensor> values, int axis, string name = "concat")
{ {
if (values.Count == 1) if (values.Count == 1)
throw new NotImplementedException("tf.concat length is 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 /// A `Tensor` with the same data as `input`, but its shape has an additional
/// dimension of size 1 added. /// dimension of size 1 added.
/// </returns> /// </returns>
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); => array_ops.expand_dims(input, axis, name, dim);


/// <summary> /// <summary>
@@ -58,14 +58,14 @@ namespace Tensorflow
/// <param name="value"></param> /// <param name="value"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor fill<T>(Tensor dims, T value, string name = null)
public Tensor fill<T>(Tensor dims, T value, string name = null)
=> gen_array_ops.fill(dims, value, name: name); => gen_array_ops.fill(dims, value, name: name);


/// <summary> /// <summary>
/// Return the elements, either from `x` or `y`, depending on the `condition`. /// Return the elements, either from `x` or `y`, depending on the `condition`.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static Tensor where<Tx, Ty>(Tensor condition, Tx x, Ty y, string name = null)
public Tensor where<Tx, Ty>(Tensor condition, Tx x, Ty y, string name = null)
=> array_ops.where(condition, x, y, name); => array_ops.where(condition, x, y, name);


/// <summary> /// <summary>
@@ -76,10 +76,10 @@ namespace Tensorflow
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="conjugate"></param> /// <param name="conjugate"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor transpose<T1>(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false)
public Tensor transpose<T1>(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false)
=> array_ops.transpose(a, perm, name, conjugate); => 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); => gen_array_ops.squeeze(input, axis, name);


/// <summary> /// <summary>
@@ -89,10 +89,10 @@ namespace Tensorflow
/// <param name="axis"></param> /// <param name="axis"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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); => 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 on_value = null,
Tensor off_value = null, Tensor off_value = null,
TF_DataType dtype = TF_DataType.DtInvalid, TF_DataType dtype = TF_DataType.DtInvalid,
@@ -110,7 +110,7 @@ namespace Tensorflow
/// </param> /// </param>
/// <param name="name">A name for the operation (optional).</param> /// <param name="name">A name for the operation (optional).</param>
/// <returns>A `Tensor`. Has the same type as `input`.</returns> /// <returns>A `Tensor`. Has the same type as `input`.</returns>
public static Tensor placeholder_with_default<T>(T input, int[] shape, string name = null)
public Tensor placeholder_with_default<T>(T input, int[] shape, string name = null)
=> gen_array_ops.placeholder_with_default(input, shape, name: name); => gen_array_ops.placeholder_with_default(input, shape, name: name);
} }
} }

+ 3
- 3
src/TensorFlowNET.Core/APIs/tf.control.cs View File

@@ -18,9 +18,9 @@ using System;


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
public static Tensor while_loop(Func<Tensor, Tensor> cond, Func<Tensor, Tensor> body, Tensor[] loop_vars,
public Tensor while_loop(Func<Tensor, Tensor> cond, Func<Tensor, Tensor> body, Tensor[] loop_vars,
TensorShape shape_invariants = null, TensorShape shape_invariants = null,
int parallel_iterations = 10, int parallel_iterations = 10,
bool back_prop = true, bool back_prop = true,
@@ -37,7 +37,7 @@ namespace Tensorflow
maximum_iterations: maximum_iterations, maximum_iterations: maximum_iterations,
return_same_structure: return_same_structure); 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); => ops.control_dependencies(control_inputs);
} }
} }

+ 5
- 3
src/TensorFlowNET.Core/APIs/tf.distributions.cs View File

@@ -16,11 +16,13 @@


namespace Tensorflow 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, Tensor scale,
bool validate_args = false, bool validate_args = false,
bool allow_nan_stats = true, bool allow_nan_stats = true,


+ 2
- 2
src/TensorFlowNET.Core/APIs/tf.exp.cs View File

@@ -16,9 +16,9 @@


namespace Tensorflow 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); string name = null) => gen_math_ops.exp(x, name);


} }


+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.gradients.cs View File

@@ -16,9 +16,9 @@


namespace Tensorflow 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[] xs,
Tensor[] grad_ys = null, Tensor[] grad_ys = null,
string name = "gradients", string name = "gradients",
@@ -36,7 +36,7 @@ namespace Tensorflow
stop_gradients: stop_gradients); stop_gradients: stop_gradients);
} }


public static Tensor[] gradients(Tensor ys,
public Tensor[] gradients(Tensor ys,
Tensor[] xs, Tensor[] xs,
Tensor[] grad_ys = null, Tensor[] grad_ys = null,
string name = "gradients", string name = "gradients",
@@ -54,7 +54,7 @@ namespace Tensorflow
stop_gradients: stop_gradients); stop_gradients: stop_gradients);
} }


public static Tensor[] gradients(Tensor ys,
public Tensor[] gradients(Tensor ys,
Tensor xs, Tensor xs,
Tensor[] grad_ys = null, Tensor[] grad_ys = null,
string name = "gradients", string name = "gradients",


+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.graph.cs View File

@@ -16,15 +16,15 @@


namespace Tensorflow 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(); return ops.get_default_graph();
} }


public static Graph Graph()
public Graph Graph()
=> new Graph(); => new Graph();
} }
} }

+ 8
- 8
src/TensorFlowNET.Core/APIs/tf.init.cs View File

@@ -18,14 +18,14 @@ using Tensorflow.Operations.Initializers;


namespace Tensorflow 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, string default_name = null,
Tensor[] values = null, Tensor[] values = null,
bool? reuse = null, bool? reuse = null,
@@ -35,7 +35,7 @@ namespace Tensorflow
reuse: reuse, reuse: reuse,
auxiliary_name_scope: auxiliary_name_scope); 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, string default_name = null,
Tensor[] values = null, Tensor[] values = null,
bool? reuse = null, bool? reuse = null,
@@ -45,7 +45,7 @@ namespace Tensorflow
reuse: reuse, reuse: reuse,
auxiliary_name_scope: auxiliary_name_scope); 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, float stddev = 1.0f,
int? seed = null, int? seed = null,
TF_DataType dtype = TF_DataType.DtInvalid) => new TruncatedNormal(mean: mean, TF_DataType dtype = TF_DataType.DtInvalid) => new TruncatedNormal(mean: mean,


+ 5
- 5
src/TensorFlowNET.Core/APIs/tf.io.cs View File

@@ -19,14 +19,14 @@ using Tensorflow.IO;


namespace Tensorflow 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<string, Tensor> input_map = null, Dictionary<string, Tensor> input_map = null,
string[] return_elements = null, string[] return_elements = null,
string name = null, string name = null,


+ 9
- 6
src/TensorFlowNET.Core/APIs/tf.layers.cs View File

@@ -16,14 +16,17 @@


using Tensorflow.Keras.Layers; using Tensorflow.Keras.Layers;
using Tensorflow.Operations.Activation; using Tensorflow.Operations.Activation;
using static Tensorflow.Binding;


namespace Tensorflow 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 filters,
int[] kernel_size, int[] kernel_size,
int[] strides = null, int[] strides = null,
@@ -80,7 +83,7 @@ namespace Tensorflow
/// <param name="renorm"></param> /// <param name="renorm"></param>
/// <param name="renorm_momentum"></param> /// <param name="renorm_momentum"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor batch_normalization(Tensor inputs,
public Tensor batch_normalization(Tensor inputs,
int axis = -1, int axis = -1,
float momentum = 0.99f, float momentum = 0.99f,
float epsilon = 0.001f, float epsilon = 0.001f,
@@ -124,7 +127,7 @@ namespace Tensorflow
/// <param name="data_format"></param> /// <param name="data_format"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor max_pooling2d(Tensor inputs,
public Tensor max_pooling2d(Tensor inputs,
int[] pool_size, int[] pool_size,
int[] strides, int[] strides,
string padding = "valid", string padding = "valid",
@@ -140,7 +143,7 @@ namespace Tensorflow
return layer.apply(inputs); return layer.apply(inputs);
} }


public static Tensor dense(Tensor inputs,
public Tensor dense(Tensor inputs,
int units, int units,
IActivation activation = null, IActivation activation = null,
bool use_bias = true, bool use_bias = true,


+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.linalg.cs View File

@@ -16,15 +16,15 @@


namespace Tensorflow 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); => 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); => 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); => gen_math_ops.batch_mat_mul(x, y);
} }
} }

+ 2
- 2
src/TensorFlowNET.Core/APIs/tf.loss.cs View File

@@ -16,8 +16,8 @@


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
public static LossesImpl losses => new LossesImpl();
public LossesImpl losses => new LossesImpl();
} }
} }

+ 58
- 58
src/TensorFlowNET.Core/APIs/tf.math.cs View File

@@ -16,9 +16,9 @@


namespace Tensorflow 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); => math_ops.abs(x, name);


/// <summary> /// <summary>
@@ -27,7 +27,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor acos(Tensor x, string name = null)
public Tensor acos(Tensor x, string name = null)
=> gen_math_ops.acos(x, name); => gen_math_ops.acos(x, name);


/// <summary> /// <summary>
@@ -36,10 +36,10 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor asin(Tensor x, string name = null)
public Tensor asin(Tensor x, string name = null)
=> gen_math_ops.asin(x, name); => gen_math_ops.asin(x, name);


public static Tensor add<Tx, Ty>(Tx a, Ty b, string name = null)
public Tensor add<Tx, Ty>(Tx a, Ty b, string name = null)
=> gen_math_ops.add(a, b, name: name); => gen_math_ops.add(a, b, name: name);


/// <summary> /// <summary>
@@ -48,19 +48,19 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor atan(Tensor x, string name = null)
public Tensor atan(Tensor x, string name = null)
=> gen_math_ops.atan(x, name); => 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); => 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); => 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); => 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); => gen_math_ops.is_nan(input, name);


/// <summary> /// <summary>
@@ -69,7 +69,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor ceil(Tensor x, string name = null)
public Tensor ceil(Tensor x, string name = null)
=> gen_math_ops.ceil(x, name); => gen_math_ops.ceil(x, name);


/// <summary> /// <summary>
@@ -78,7 +78,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor sin(Tensor x, string name = null)
public Tensor sin(Tensor x, string name = null)
=> gen_math_ops.sin(x, name); => gen_math_ops.sin(x, name);


/// <summary> /// <summary>
@@ -87,7 +87,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor sinh(Tensor x, string name = null)
public Tensor sinh(Tensor x, string name = null)
=> gen_math_ops.sinh(x, name); => gen_math_ops.sinh(x, name);


/// <summary> /// <summary>
@@ -96,7 +96,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor cos(Tensor x, string name = null)
public Tensor cos(Tensor x, string name = null)
=> gen_math_ops.cos(x, name); => gen_math_ops.cos(x, name);


/// <summary> /// <summary>
@@ -105,13 +105,13 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor cosh(Tensor x, string name = null)
public Tensor cosh(Tensor x, string name = null)
=> gen_math_ops.cosh(x, name); => 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); => 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); => gen_math_ops.tanh(x, name);


/// <summary> /// <summary>
@@ -120,7 +120,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor floor(Tensor x, string name = null)
public Tensor floor(Tensor x, string name = null)
=> gen_math_ops.floor(x, name); => gen_math_ops.floor(x, name);


/// <summary> /// <summary>
@@ -132,7 +132,7 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor greater<Tx, Ty>(Tx x, Ty y, string name = null)
public Tensor greater<Tx, Ty>(Tx x, Ty y, string name = null)
=> gen_math_ops.greater(x, y, name); => gen_math_ops.greater(x, y, name);


/// <summary> /// <summary>
@@ -144,7 +144,7 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor greater_equal<Tx, Ty>(Tx x, Ty y, string name = null)
public Tensor greater_equal<Tx, Ty>(Tx x, Ty y, string name = null)
=> gen_math_ops.greater_equal(x, y, name); => gen_math_ops.greater_equal(x, y, name);


/// <summary> /// <summary>
@@ -156,7 +156,7 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor less<Tx, Ty>(Tx x, Ty y, string name = null)
public Tensor less<Tx, Ty>(Tx x, Ty y, string name = null)
=> gen_math_ops.less(x, y, name); => gen_math_ops.less(x, y, name);


/// <summary> /// <summary>
@@ -165,7 +165,7 @@ namespace Tensorflow
/// <param name="x">A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.</param> /// <param name="x">A `Tensor`. Must be one of the following types: `bfloat16`, `half`, `float32`, `float64`.</param>
/// <param name="name">A name for the operation (optional).</param> /// <param name="name">A name for the operation (optional).</param>
/// <returns>A `Tensor`. Has the same type as `x`.</returns> /// <returns>A `Tensor`. Has the same type as `x`.</returns>
public static Tensor lgamma(Tensor x, string name = null)
public Tensor lgamma(Tensor x, string name = null)
=> gen_math_ops.lgamma(x, name: name); => gen_math_ops.lgamma(x, name: name);


/// <summary> /// <summary>
@@ -177,7 +177,7 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor less_equal<Tx, Ty>(Tx x, Ty y, string name = null)
public Tensor less_equal<Tx, Ty>(Tx x, Ty y, string name = null)
=> gen_math_ops.less_equal(x, y, name); => gen_math_ops.less_equal(x, y, name);


/// <summary> /// <summary>
@@ -186,19 +186,19 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor log1p(Tensor x, string name = null)
public Tensor log1p(Tensor x, string name = null)
=> gen_math_ops.log1p(x, name); => 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); => 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); => 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); => 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); => gen_math_ops.logical_xor(x, y, name);


/// <summary> /// <summary>
@@ -209,28 +209,28 @@ namespace Tensorflow
/// <param name="clip_value_max"></param> /// <param name="clip_value_max"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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); => 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); => 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); => 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); => 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); => gen_math_ops.sign(a, name);


public static Tensor subtract<T>(Tensor x, T[] y, string name = null) where T : struct
public Tensor subtract<T>(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); => 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); => 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); => gen_math_ops.equal(x, y, name);


/// <summary> /// <summary>
@@ -240,7 +240,7 @@ namespace Tensorflow
/// <param name="x"></param> /// <param name="x"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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); => gen_math_ops.atan2(y, x, name);


/// <summary> /// <summary>
@@ -253,7 +253,7 @@ namespace Tensorflow
/// <param name="keep_dims"></param> /// <param name="keep_dims"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor max<Tx, Ty>(Tx input, Ty axis, bool keep_dims = false, string name = null)
public Tensor max<Tx, Ty>(Tx input, Ty axis, bool keep_dims = false, string name = null)
=> gen_math_ops._max(input, axis, keep_dims: keep_dims, name: name); => gen_math_ops._max(input, axis, keep_dims: keep_dims, name: name);


/// <summary> /// <summary>
@@ -266,7 +266,7 @@ namespace Tensorflow
/// <param name="keep_dims"></param> /// <param name="keep_dims"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor min<Tx, Ty>(Tx input, Ty axis, bool keep_dims = false, string name = null)
public Tensor min<Tx, Ty>(Tx input, Ty axis, bool keep_dims = false, string name = null)
=> gen_math_ops._min(input, axis, keep_dims: keep_dims, name: name); => gen_math_ops._min(input, axis, keep_dims: keep_dims, name: name);


/// <summary> /// <summary>
@@ -278,7 +278,7 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor maximum<T1, T2>(T1 x, T2 y, string name = null)
public Tensor maximum<T1, T2>(T1 x, T2 y, string name = null)
=> gen_math_ops.maximum(x, y, name: name); => gen_math_ops.maximum(x, y, name: name);


/// <summary> /// <summary>
@@ -290,13 +290,13 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor minimum<T1, T2>(T1 x, T2 y, string name = null)
public Tensor minimum<T1, T2>(T1 x, T2 y, string name = null)
=> gen_math_ops.minimum(x, y, name: name); => gen_math_ops.minimum(x, y, name: name);


public static Tensor multiply<Tx, Ty>(Tx x, Ty y)
public Tensor multiply<Tx, Ty>(Tx x, Ty y)
=> gen_math_ops.mul(x, 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); => gen_math_ops.neg(x, name);


/// <summary> /// <summary>
@@ -306,13 +306,13 @@ namespace Tensorflow
/// <param name="y"></param> /// <param name="y"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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); => math_ops.div(x, y, name: name);


public static Tensor divide<T>(Tensor x, T[] y, string name = null) where T : struct
public Tensor divide<T>(Tensor x, T[] y, string name = null) where T : struct
=> x / ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y"); => x / ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y");


public static Tensor pow<T1, T2>(T1 x, T2 y)
public Tensor pow<T1, T2>(T1 x, T2 y)
=> gen_math_ops.pow(x, y); => gen_math_ops.pow(x, y);


/// <summary> /// <summary>
@@ -321,14 +321,14 @@ namespace Tensorflow
/// <param name="input"></param> /// <param name="input"></param>
/// <param name="axis"></param> /// <param name="axis"></param>
/// <returns></returns> /// <returns></returns>
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) if(!axis.HasValue && reduction_indices.HasValue)
return math_ops.reduce_sum(input, reduction_indices.Value); return math_ops.reduce_sum(input, reduction_indices.Value);
return math_ops.reduce_sum(input); 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); => math_ops.reduce_sum(input, axis);


/// <summary> /// <summary>
@@ -339,34 +339,34 @@ namespace Tensorflow
/// <param name="keepdims"></param> /// <param name="keepdims"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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); => 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); => math_ops.reduce_min(input_tensor, axis, keepdims, name);


public static Tensor sigmoid<T>(T x, string name = null)
public Tensor sigmoid<T>(T x, string name = null)
=> math_ops.sigmoid(x, name: name); => 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); => 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); => 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); => 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); => 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); => 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); => 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); => gen_math_ops.square(x, name: name);
} }
} }

+ 24
- 22
src/TensorFlowNET.Core/APIs/tf.nn.cs View File

@@ -20,11 +20,13 @@ using static Tensorflow.Python;


namespace Tensorflow 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) string data_format= "NHWC", int[] dilations= null, string name = null)
{ {
var parameters = new Conv2dParams var parameters = new Conv2dParams
@@ -54,7 +56,7 @@ namespace Tensorflow
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="rate">A scalar `Tensor` with the same type as `x`.</param> /// <param name="rate">A scalar `Tensor` with the same type as `x`.</param>
/// <returns>A Tensor of the same shape of `x`.</returns> /// <returns>A Tensor of the same shape of `x`.</returns>
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) float? rate = null)
{ {
Tensor keep = null; Tensor keep = null;
@@ -74,17 +76,17 @@ namespace Tensorflow
/// <param name="swap_memory"></param> /// <param name="swap_memory"></param>
/// <param name="time_major"></param> /// <param name="time_major"></param>
/// <returns>A pair (outputs, state)</returns> /// <returns>A pair (outputs, state)</returns>
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, Tensor sequence_length = null, TF_DataType dtype = TF_DataType.DtInvalid,
int? parallel_iterations = null, bool swap_memory = false, bool time_major = false) int? parallel_iterations = null, bool swap_memory = false, bool time_major = false)
=> rnn.dynamic_rnn(cell, inputs, sequence_length: sequence_length, dtype: dtype, => rnn.dynamic_rnn(cell, inputs, sequence_length: sequence_length, dtype: dtype,
parallel_iterations: parallel_iterations, swap_memory: swap_memory, parallel_iterations: parallel_iterations, swap_memory: swap_memory,
time_major: time_major); 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); => gen_nn_ops.elu(features, name: name);


public static (Tensor, Tensor) moments(Tensor x,
public (Tensor, Tensor) moments(Tensor x,
int[] axes, int[] axes,
string name = null, string name = null,
bool keep_dims = false) => nn_impl.moments(x, bool keep_dims = false) => nn_impl.moments(x,
@@ -92,7 +94,7 @@ namespace Tensorflow
name: name, name: name,
keep_dims: keep_dims); keep_dims: keep_dims);


public static Tensor embedding_lookup(RefVariable @params,
public Tensor embedding_lookup(RefVariable @params,
Tensor ids, Tensor ids,
string partition_strategy = "mod", string partition_strategy = "mod",
string name = null) => embedding_ops._embedding_lookup_and_transform(@params, string name = null) => embedding_ops._embedding_lookup_and_transform(@params,
@@ -100,7 +102,7 @@ namespace Tensorflow
partition_strategy: partition_strategy, partition_strategy: partition_strategy,
name: name); name: name);


public static Tensor embedding_lookup(Tensor @params,
public Tensor embedding_lookup(Tensor @params,
Tensor ids, Tensor ids,
string partition_strategy = "mod", string partition_strategy = "mod",
string name = null) => embedding_ops._embedding_lookup_and_transform(new Tensor[] { @params }, string name = null) => embedding_ops._embedding_lookup_and_transform(new Tensor[] { @params },
@@ -108,11 +110,11 @@ namespace Tensorflow
partition_strategy: partition_strategy, partition_strategy: partition_strategy,
name: name); 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 scale,
RefVariable offset, RefVariable offset,
Tensor mean = null, Tensor mean = null,
@@ -126,18 +128,18 @@ namespace Tensorflow
is_training: is_training, is_training: is_training,
name: name); 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); => 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); => 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); => 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 => 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); => gen_nn_ops.softmax(logits, name);


/// <summary> /// <summary>
@@ -158,7 +160,7 @@ namespace Tensorflow
/// <param name="logits"></param> /// <param name="logits"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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) Tensor logits = null, string name = null)
=> nn_ops.sparse_softmax_cross_entropy_with_logits(labels: labels, logits: logits, name: name); => nn_ops.sparse_softmax_cross_entropy_with_logits(labels: labels, logits: logits, name: name);


@@ -170,7 +172,7 @@ namespace Tensorflow
/// <param name="dim"></param> /// <param name="dim"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
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 => 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); 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); => nn_ops.softmax_cross_entropy_with_logits_v2_helper(labels, logits, axis: axis, name: name);
} }
} }


+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.ops.cs View File

@@ -16,12 +16,12 @@


namespace Tensorflow 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); => 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); => get_default_graph().get_collection(key, scope: scope);


/// <summary> /// <summary>
@@ -31,7 +31,7 @@ namespace Tensorflow
/// <param name="default_name">The default name to use if the name argument is None.</param> /// <param name="default_name">The default name to use if the name argument is None.</param>
/// <param name="values">The list of Tensor arguments that are passed to the op function.</param> /// <param name="values">The list of Tensor arguments that are passed to the op function.</param>
/// <returns>The scope name.</returns> /// <returns>The scope name.</returns>
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); => new ops.NameScope(name, default_name, values);
} }
} }

+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.random.cs View File

@@ -16,7 +16,7 @@


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
/// <summary> /// <summary>
/// Outputs random values from a normal distribution. /// Outputs random values from a normal distribution.
@@ -28,21 +28,21 @@ namespace Tensorflow
/// <param name="seed"></param> /// <param name="seed"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <returns></returns> /// <returns></returns>
public static Tensor random_normal(int[] shape,
public Tensor random_normal(int[] shape,
float mean = 0.0f, float mean = 0.0f,
float stddev = 1.0f, float stddev = 1.0f,
TF_DataType dtype = TF_DataType.TF_FLOAT, TF_DataType dtype = TF_DataType.TF_FLOAT,
int? seed = null, int? seed = null,
string name = null) => random_ops.random_normal(shape, mean, stddev, dtype, seed, name); 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 minval = 0,
float maxval = 1, float maxval = 1,
TF_DataType dtype = TF_DataType.TF_FLOAT, TF_DataType dtype = TF_DataType.TF_FLOAT,
int? seed = null, int? seed = null,
string name = null) => random_ops.random_uniform(shape, minval, maxval, dtype, seed, name); 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 mean = 0.0f,
float stddev = 1.0f, float stddev = 1.0f,
TF_DataType dtype = TF_DataType.TF_FLOAT, TF_DataType dtype = TF_DataType.TF_FLOAT,


+ 2
- 2
src/TensorFlowNET.Core/APIs/tf.reduce_logsumexp.cs View File

@@ -16,9 +16,9 @@


namespace Tensorflow 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, int[] axis = null,
bool keepdims = false, bool keepdims = false,
string name = null) => math_ops.reduce_logsumexp(input_tensor, axis, keepdims, name); string name = null) => math_ops.reduce_logsumexp(input_tensor, axis, keepdims, name);


+ 3
- 3
src/TensorFlowNET.Core/APIs/tf.reshape.cs View File

@@ -16,13 +16,13 @@


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
public static Tensor reshape(Tensor tensor,
public Tensor reshape(Tensor tensor,
Tensor shape, Tensor shape,
string name = null) => gen_array_ops.reshape(tensor, shape, name); string name = null) => gen_array_ops.reshape(tensor, shape, name);


public static Tensor reshape(Tensor tensor,
public Tensor reshape(Tensor tensor,
int[] shape, int[] shape,
string name = null) => gen_array_ops.reshape(tensor, shape, name); string name = null) => gen_array_ops.reshape(tensor, shape, name);
} }


+ 3
- 3
src/TensorFlowNET.Core/APIs/tf.summary.cs View File

@@ -16,11 +16,11 @@


namespace Tensorflow 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); => summary.scalar(name, tensor);
} }
} }

+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.tensor.cs View File

@@ -16,12 +16,12 @@


namespace Tensorflow 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); 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 begin_mask = 0,
int end_mask = 0, int end_mask = 0,
int ellipsis_mask = 0, int ellipsis_mask = 0,
@@ -38,7 +38,7 @@ namespace Tensorflow
shrink_axis_mask: shrink_axis_mask, shrink_axis_mask: shrink_axis_mask,
name: name); name: name);


public static Tensor strided_slice<T>(Tensor input, T[] begin, T[] end, T[] strides = null,
public Tensor strided_slice<T>(Tensor input, T[] begin, T[] end, T[] strides = null,
int begin_mask = 0, int begin_mask = 0,
int end_mask = 0, int end_mask = 0,
int ellipsis_mask = 0, int ellipsis_mask = 0,


+ 3
- 3
src/TensorFlowNET.Core/APIs/tf.tile.cs View File

@@ -18,12 +18,12 @@ using NumSharp;


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
public static Tensor tile(Tensor input,
public Tensor tile(Tensor input,
Tensor multiples, Tensor multiples,
string name = null) => gen_array_ops.tile(input, multiples, name); string name = null) => gen_array_ops.tile(input, multiples, name);
public static Tensor tile(NDArray input,
public Tensor tile(NDArray input,
int[] multiples, int[] multiples,
string name = null) => gen_array_ops.tile(input, multiples, name); string name = null) => gen_array_ops.tile(input, multiples, name);




+ 4
- 4
src/TensorFlowNET.Core/APIs/tf.variable.cs View File

@@ -18,21 +18,21 @@ using System.Collections.Generic;


namespace Tensorflow 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<VariableV1>) return (ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES, scope) as List<VariableV1>)
.ToArray(); .ToArray();
} }


public static Operation global_variables_initializer()
public Operation global_variables_initializer()
{ {
var g = variables.global_variables(); var g = variables.global_variables();
return variables.variables_initializer(g.ToArray()); return variables.variables_initializer(g.ToArray());
} }


public static RefVariable get_variable(string name,
public RefVariable get_variable(string name,
TensorShape shape = null, TensorShape shape = null,
TF_DataType dtype = TF_DataType.DtInvalid, TF_DataType dtype = TF_DataType.DtInvalid,
object initializer = null, // IInitializer or Tensor object initializer = null, // IInitializer or Tensor


+ 11
- 0
src/TensorFlowNET.Core/Binding.cs View File

@@ -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<tensorflow>();
}
}

+ 1
- 0
src/TensorFlowNET.Core/Clustering/KMeans.cs View File

@@ -15,6 +15,7 @@
******************************************************************************/ ******************************************************************************/


using System; using System;
using static Tensorflow.Binding;


namespace Tensorflow.Clustering namespace Tensorflow.Clustering
{ {


+ 1
- 0
src/TensorFlowNET.Core/Framework/meta_graph.py.cs View File

@@ -22,6 +22,7 @@ using System.Linq;
using Tensorflow.Operations; using Tensorflow.Operations;
using static Tensorflow.CollectionDef; using static Tensorflow.CollectionDef;
using static Tensorflow.MetaGraphDef.Types; using static Tensorflow.MetaGraphDef.Types;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/Gradients/array_grad.cs View File

@@ -18,6 +18,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Tensorflow.Framework; using Tensorflow.Framework;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow.Gradients namespace Tensorflow.Gradients
{ {


+ 1
- 0
src/TensorFlowNET.Core/Gradients/math_grad.cs View File

@@ -18,6 +18,7 @@ using System;
using System.Linq; using System.Linq;
using Tensorflow.Operations; using Tensorflow.Operations;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow.Gradients namespace Tensorflow.Gradients
{ {


+ 1
- 0
src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs View File

@@ -16,6 +16,7 @@


using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/Graphs/Graph.Operation.cs View File

@@ -18,6 +18,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 1
src/TensorFlowNET.Core/IPyClass.cs View File

@@ -22,7 +22,7 @@ namespace Tensorflow
/// Called when the instance is created. /// Called when the instance is created.
/// </summary> /// </summary>
/// <param name="args"></param> /// <param name="args"></param>
void __init__(IPyClass self, dynamic args);
void __init__(IPyClass self);


void __enter__(IPyClass self); void __enter__(IPyClass self);




+ 1
- 0
src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs View File

@@ -17,6 +17,7 @@
using System; using System;
using System.Linq; using System.Linq;
using Tensorflow.Keras.Utils; using Tensorflow.Keras.Utils;
using static Tensorflow.Binding;


namespace Tensorflow.Keras.Layers namespace Tensorflow.Keras.Layers
{ {


+ 2
- 2
src/TensorFlowNET.Core/Keras/Layers/Dense.cs View File

@@ -19,7 +19,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Tensorflow.Keras.Engine; using Tensorflow.Keras.Engine;
using Tensorflow.Operations.Activation; using Tensorflow.Operations.Activation;
using static Tensorflow.tf;
using static Tensorflow.Binding;


namespace Tensorflow.Keras.Layers namespace Tensorflow.Keras.Layers
{ {
@@ -86,7 +86,7 @@ namespace Tensorflow.Keras.Layers
} }


if (use_bias) if (use_bias)
outputs = nn.bias_add(outputs, bias);
outputs = tf.nn.bias_add(outputs, bias);
if (activation != null) if (activation != null)
return activation.Activate(outputs); return activation.Activate(outputs);




+ 2
- 0
src/TensorFlowNET.Core/Keras/Layers/Embedding.cs View File

@@ -14,6 +14,8 @@
limitations under the License. limitations under the License.
******************************************************************************/ ******************************************************************************/


using static Tensorflow.Binding;

namespace Tensorflow.Keras.Layers namespace Tensorflow.Keras.Layers
{ {
public class Embedding : Layer public class Embedding : Layer


+ 1
- 0
src/TensorFlowNET.Core/Keras/Layers/Layer.cs View File

@@ -21,6 +21,7 @@ using Tensorflow.Keras.Engine;
using Tensorflow.Keras.Utils; using Tensorflow.Keras.Utils;
using Tensorflow.Train; using Tensorflow.Train;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow.Keras.Layers namespace Tensorflow.Keras.Layers
{ {


+ 2
- 2
src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs View File

@@ -1,4 +1,4 @@
using static Tensorflow.tf;
using static Tensorflow.Binding;


namespace Tensorflow.Keras.Layers namespace Tensorflow.Keras.Layers
{ {
@@ -9,7 +9,7 @@ namespace Tensorflow.Keras.Layers
int[] strides, int[] strides,
string padding = "valid", string padding = "valid",
string data_format = null, 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, strides,
padding: padding, padding: padding,
data_format: data_format, data_format: data_format,


+ 1
- 0
src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs View File

@@ -17,6 +17,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static Tensorflow.Binding;


namespace Tensorflow.Keras.Utils namespace Tensorflow.Keras.Utils
{ {


+ 2
- 1
src/TensorFlowNET.Core/Keras/backend.cs View File

@@ -17,6 +17,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow.Keras namespace Tensorflow.Keras
{ {
@@ -28,7 +29,7 @@ namespace Tensorflow.Keras
//Func<Array, bool> py_any = any; //Func<Array, bool> py_any = any;
//Func<double, double, double, IEnumerable<double>> py_slice = slice; //Func<double, double, double, IEnumerable<double>> py_slice = slice;


public static Session _SESSION = Tensorflow.tf.defaultSession;
public static Session _SESSION = tf.defaultSession;
public static Graph _GRAPH = null; public static Graph _GRAPH = null;
public static Dictionary<Graph, GraphLearningPhase> _GRAPH_LEARNING_PHASES; public static Dictionary<Graph, GraphLearningPhase> _GRAPH_LEARNING_PHASES;
//Dictionary<Graph, Dictionary<string, int>> PER_GRAPH_LAYER_NAME_UIDS; //Dictionary<Graph, Dictionary<string, int>> PER_GRAPH_LAYER_NAME_UIDS;


+ 2
- 2
src/TensorFlowNET.Core/Keras/tf.keras.cs View File

@@ -2,9 +2,9 @@


namespace Tensorflow namespace Tensorflow
{ {
public static partial class tf
public partial class tensorflow
{ {
public static class keras
public class keras
{ {
public static Initializers initializers => new Initializers(); public static Initializers initializers => new Initializers();
} }


+ 1
- 0
src/TensorFlowNET.Core/Layers/Layer.cs View File

@@ -17,6 +17,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow.Layers namespace Tensorflow.Layers
{ {


+ 1
- 0
src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs View File

@@ -17,6 +17,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 1
src/TensorFlowNET.Core/Operations/NnOps/rnn.cs View File

@@ -19,7 +19,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using static Tensorflow.Python; using static Tensorflow.Python;
using Tensorflow.Util; using Tensorflow.Util;
using NumSharp;
using static Tensorflow.Binding;


namespace Tensorflow.Operations namespace Tensorflow.Operations
{ {


+ 1
- 0
src/TensorFlowNET.Core/Operations/array_ops.py.cs View File

@@ -18,6 +18,7 @@ using NumSharp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;
namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/Operations/gen_image_ops.py.cs View File

@@ -16,6 +16,7 @@


using System; using System;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 3
- 10
src/TensorFlowNET.Core/Python.cs View File

@@ -66,12 +66,10 @@ namespace Tensorflow
return Enumerable.Range(start, end - start); return Enumerable.Range(start, end - start);
} }


public static T New<T>(object args) where T : IPyClass
public static T New<T>() where T : IPyClass, new()
{ {
var instance = Activator.CreateInstance<T>();

instance.__init__(instance, args);

var instance = new T();
instance.__init__(instance);
return instance; return instance;
} }


@@ -347,9 +345,4 @@ namespace Tensorflow


void __exit__(); void __exit__();
} }

public class PyObject<T> where T : IPyClass
{
public T Instance { get; set; }
}
} }

+ 1
- 1
src/TensorFlowNET.Core/Sessions/Session.cs View File

@@ -15,7 +15,7 @@
******************************************************************************/ ******************************************************************************/


using System; using System;
using System.Runtime.InteropServices;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/Tensors/constant_op.cs View File

@@ -16,6 +16,7 @@


using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 9
- 9
src/TensorFlowNET.Core/Tensors/tf.constant.cs View File

@@ -18,11 +18,11 @@ using NumSharp;


namespace Tensorflow 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(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, TF_DataType dtype = TF_DataType.DtInvalid,
int[] shape = null, int[] shape = null,
string name = "Const", string name = "Const",
@@ -33,30 +33,30 @@ namespace Tensorflow
verify_shape: verify_shape, verify_shape: verify_shape,
allow_broadcast: false); allow_broadcast: false);


public static Tensor constant(string value,
public Tensor constant(string value,
string name = "Const") => constant_op._constant_impl(value, string name = "Const") => constant_op._constant_impl(value,
tf.@string,
@string,
new int[] { 1 }, new int[] { 1 },
name, name,
verify_shape: false, verify_shape: false,
allow_broadcast: false); allow_broadcast: false);


public static Tensor constant(float value,
public Tensor constant(float value,
int shape, int shape,
string name = "Const") => constant_op._constant_impl(value, string name = "Const") => constant_op._constant_impl(value,
tf.float32,
float32,
new int[] { shape }, new int[] { shape },
name, name,
verify_shape: false, verify_shape: false,
allow_broadcast: 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); => 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); => array_ops.ones(shape, dtype, name);


public static Tensor size(Tensor input,
public Tensor size(Tensor input,
string name = null, string name = null,
TF_DataType out_type = TF_DataType.TF_INT32) => array_ops.size(input, TF_DataType out_type = TF_DataType.TF_INT32) => array_ops.size(input,
name, name,


+ 1
- 0
src/TensorFlowNET.Core/Train/Optimizer.cs View File

@@ -20,6 +20,7 @@ using System.Linq;
using Tensorflow.Framework; using Tensorflow.Framework;
using Tensorflow.Train; using Tensorflow.Train;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/Train/Saving/Saver.cs View File

@@ -19,6 +19,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/Train/SlotCreator.cs View File

@@ -17,6 +17,7 @@
using System; using System;
using Tensorflow.Operations.Initializers; using Tensorflow.Operations.Initializers;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow.Train namespace Tensorflow.Train
{ {


+ 10
- 8
src/TensorFlowNET.Core/Train/tf.optimizers.cs View File

@@ -19,28 +19,30 @@ using Tensorflow.Train;


namespace Tensorflow 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); => 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); => 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); => 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, bool clear_devices = false,
string import_scope = "") => saver._import_meta_graph_with_return_elements(meta_graph_or_file, string import_scope = "") => saver._import_meta_graph_with_return_elements(meta_graph_or_file,
clear_devices, clear_devices,
import_scope).Item1; import_scope).Item1;


public static (MetaGraphDef, Dictionary<string, RefVariable>) export_meta_graph(string filename = "",
public (MetaGraphDef, Dictionary<string, RefVariable>) export_meta_graph(string filename = "",
bool as_text = false, bool as_text = false,
bool clear_devices = false, bool clear_devices = false,
bool clear_extraneous_savers = false, bool clear_extraneous_savers = false,


+ 1
- 0
src/TensorFlowNET.Core/Variables/_VariableStore.cs View File

@@ -16,6 +16,7 @@


using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


+ 1
- 0
src/TensorFlowNET.Core/ops.py.cs View File

@@ -21,6 +21,7 @@ using Google.Protobuf;
using System.Linq; using System.Linq;
using NumSharp; using NumSharp;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace Tensorflow namespace Tensorflow
{ {


src/TensorFlowNET.Core/tf.cs → src/TensorFlowNET.Core/tensorflow.cs View File

@@ -18,25 +18,25 @@ using Tensorflow.Eager;


namespace Tensorflow 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>(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>(T data,
bool trainable = true, bool trainable = true,
bool validate_shape = true, bool validate_shape = true,
string name = null, string name = null,
@@ -49,33 +49,53 @@ namespace Tensorflow
dtype: dtype); 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); return gen_array_ops.placeholder(dtype, shape, name);
} }


public static void enable_eager_execution()
public void enable_eager_execution()
{ {
// contex = new Context(); // contex = new Context();
context.default_execution_mode = Context.EAGER_MODE; 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(); defaultSession = new Session();
return defaultSession; return defaultSession;
} }


public static Session Session(Graph graph)
public Session Session(Graph graph)
{ {
return new Session(graph); return new Session(graph);
} }


public static Session Session(SessionOptions opts)
public Session Session(SessionOptions opts)
{ {
return new Session(null, 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)
{
}
} }
} }

+ 1
- 0
src/TensorFlowNet.Benchmarks/TensorBenchmark.cs View File

@@ -2,6 +2,7 @@
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
using NumSharp; using NumSharp;
using Tensorflow; using Tensorflow;
using static Tensorflow.Binding;
namespace TensorFlowBenchmark namespace TensorFlowBenchmark
{ {


+ 1
- 1
test/TensorFlowNET.Examples.FSharp/FunctionApproximation.fs View File

@@ -6,7 +6,6 @@ open NumSharp
open Tensorflow open Tensorflow
open System open System



let run()= let run()=
let N_points = 75 // Number of points for constructing function 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_1 = 25 // Hidden layer 1
let n_hidden_layer_2 = 25 // Hidden layer 2 let n_hidden_layer_2 = 25 // Hidden layer 2


let tf = Python.New<tensorflow>()
let x = tf.placeholder(tf.float64, new TensorShape(N_points,n_input)) let x = tf.placeholder(tf.float64, new TensorShape(N_points,n_input))
let y = tf.placeholder(tf.float64, new TensorShape(n_output)) let y = tf.placeholder(tf.float64, new TensorShape(n_output))


+ 1
- 0
test/TensorFlowNET.Examples/BasicEagerApi.cs View File

@@ -1,5 +1,6 @@
using System; using System;
using Tensorflow; using Tensorflow;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/BasicModels/KMeansClustering.cs View File

@@ -20,6 +20,7 @@ using System.Diagnostics;
using Tensorflow; using Tensorflow;
using Tensorflow.Hub; using Tensorflow.Hub;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/BasicModels/LinearRegression.cs View File

@@ -18,6 +18,7 @@ using NumSharp;
using System; using System;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/BasicModels/LogisticRegression.cs View File

@@ -21,6 +21,7 @@ using System.IO;
using Tensorflow; using Tensorflow;
using Tensorflow.Hub; using Tensorflow.Hub;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 1
test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs View File

@@ -18,7 +18,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Tensorflow; using Tensorflow;
using NumSharp; using NumSharp;
using static Tensorflow.Python;
using static Tensorflow.Binding;
using System.IO; using System.IO;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;




+ 1
- 0
test/TensorFlowNET.Examples/BasicModels/NearestNeighbor.cs View File

@@ -19,6 +19,7 @@ using System;
using Tensorflow; using Tensorflow;
using Tensorflow.Hub; using Tensorflow.Hub;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 1
test/TensorFlowNET.Examples/BasicModels/NeuralNetXor.cs View File

@@ -18,7 +18,7 @@ using System;
using NumSharp; using NumSharp;
using Tensorflow; using Tensorflow;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 2
- 2
test/TensorFlowNET.Examples/BasicOperations.cs View File

@@ -1,7 +1,7 @@
using NumSharp; using NumSharp;
using System; using System;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {
@@ -95,7 +95,7 @@ namespace TensorFlowNET.Examples
Console.WriteLine(result.ToString()); // ==> [[ 12.]] 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 // 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. // across the two matrices and a common matrix multiplication is done on the residual 2 dimensions.
// //


+ 1
- 1
test/TensorFlowNET.Examples/HelloWorld.cs View File

@@ -1,6 +1,6 @@
using System; using System;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 2
- 1
test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionCNN.cs View File

@@ -20,6 +20,7 @@ using System.Diagnostics;
using Tensorflow; using Tensorflow;
using Tensorflow.Hub; using Tensorflow.Hub;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {
@@ -27,7 +28,7 @@ namespace TensorFlowNET.Examples
/// Convolutional Neural Network classifier for Hand Written Digits /// Convolutional Neural Network classifier for Hand Written Digits
/// CNN architecture with two convolutional layers, followed by two fully-connected layers at the end. /// CNN architecture with two convolutional layers, followed by two fully-connected layers at the end.
/// Use Stochastic Gradient Descent (SGD) optimizer. /// 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
/// </summary> /// </summary>
public class DigitRecognitionCNN : IExample public class DigitRecognitionCNN : IExample
{ {


+ 2
- 1
test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionNN.cs View File

@@ -19,6 +19,7 @@ using System;
using Tensorflow; using Tensorflow;
using Tensorflow.Hub; using Tensorflow.Hub;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {
@@ -26,7 +27,7 @@ namespace TensorFlowNET.Examples
/// Neural Network classifier for Hand Written Digits /// Neural Network classifier for Hand Written Digits
/// Sample Neural Network architecture with two layers implemented for classifying MNIST digits. /// Sample Neural Network architecture with two layers implemented for classifying MNIST digits.
/// Use Stochastic Gradient Descent (SGD) optimizer. /// Use Stochastic Gradient Descent (SGD) optimizer.
/// http://www.easy-tensorflow.com/tf-tutorials/neural-networks
/// http://www.easy-tf.com/tf-tutorials/neural-networks
/// </summary> /// </summary>
public class DigitRecognitionNN : IExample public class DigitRecognitionNN : IExample
{ {


+ 1
- 0
test/TensorFlowNET.Examples/ImageProcessing/DigitRecognitionRNN.cs View File

@@ -19,6 +19,7 @@ using System;
using Tensorflow; using Tensorflow;
using Tensorflow.Hub; using Tensorflow.Hub;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 1
test/TensorFlowNET.Examples/ImageProcessing/ImageBackgroundRemoval.cs View File

@@ -2,7 +2,7 @@
using System.IO; using System.IO;
using Tensorflow; using Tensorflow;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 2
- 2
test/TensorFlowNET.Examples/ImageProcessing/ImageRecognitionInception.cs View File

@@ -6,7 +6,7 @@ using System.IO;
using Console = Colorful.Console; using Console = Colorful.Console;
using Tensorflow; using Tensorflow;
using System.Drawing; using System.Drawing;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {
@@ -89,7 +89,7 @@ namespace TensorFlowNET.Examples
Directory.CreateDirectory(dir); Directory.CreateDirectory(dir);


// get model file // 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"); Utility.Web.Download(url, dir, "inception5h.zip");




+ 2
- 2
test/TensorFlowNET.Examples/ImageProcessing/InceptionArchGoogLeNet.cs View File

@@ -3,7 +3,7 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {
@@ -93,7 +93,7 @@ namespace TensorFlowNET.Examples
Directory.CreateDirectory(dir); Directory.CreateDirectory(dir);


// get model file // 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"); Utility.Web.Download(url, dir, $"{pbFile}.tar.gz");




+ 2
- 2
test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection.cs View File

@@ -22,7 +22,7 @@ using TensorFlowNET.Examples.Utility;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Linq; using System.Linq;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {
@@ -84,7 +84,7 @@ namespace TensorFlowNET.Examples
public void PrepareData() public void PrepareData()
{ {
// get model file // 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"); Web.Download(url, modelDir, "ssd_mobilenet_v1_coco.tar.gz");


Compress.ExtractTGZ(Path.Join(modelDir, "ssd_mobilenet_v1_coco.tar.gz"), "./"); Compress.ExtractTGZ(Path.Join(modelDir, "ssd_mobilenet_v1_coco.tar.gz"), "./");


+ 4
- 3
test/TensorFlowNET.Examples/ImageProcessing/RetrainImageClassifier.cs View File

@@ -24,6 +24,7 @@ using System.Linq;
using Tensorflow; using Tensorflow;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples 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 /// 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. /// 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
/// </summary> /// </summary>
public class RetrainImageClassifier : IExample public class RetrainImageClassifier : IExample
{ {
@@ -167,7 +168,7 @@ namespace TensorFlowNET.Examples
/// weights, and then sets up all the gradients for the backward pass. /// 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: /// 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
/// </summary> /// </summary>
/// <param name="class_count"></param> /// <param name="class_count"></param>
/// <param name="final_tensor_name"></param> /// <param name="final_tensor_name"></param>
@@ -508,7 +509,7 @@ namespace TensorFlowNET.Examples
{ {
// get a set of images to teach the network about the new classes // get a set of images to teach the network about the new classes
string fileName = "flower_photos.tgz"; 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); Web.Download(url, data_dir, fileName);
Compress.ExtractTGZ(Path.Join(data_dir, fileName), data_dir); Compress.ExtractTGZ(Path.Join(data_dir, fileName), data_dir);




+ 1
- 0
test/TensorFlowNET.Examples/Keras.cs View File

@@ -4,6 +4,7 @@ using Tensorflow;
using Keras.Layers; using Keras.Layers;
using NumSharp; using NumSharp;
using Keras; using Keras;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/Program.cs View File

@@ -22,6 +22,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using Tensorflow; using Tensorflow;
using Console = Colorful.Console; using Console = Colorful.Console;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/TextProcessing/CnnTextClassification.cs View File

@@ -25,6 +25,7 @@ using Tensorflow.Sessions;
using TensorFlowNET.Examples.Text; using TensorFlowNET.Examples.Text;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/TextProcessing/NER/LstmCrfNer.cs View File

@@ -7,6 +7,7 @@ using Tensorflow;
using Tensorflow.Estimator; using Tensorflow.Estimator;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;
using static TensorFlowNET.Examples.DataHelpers; using static TensorFlowNET.Examples.DataHelpers;


namespace TensorFlowNET.Examples.Text.NER namespace TensorFlowNET.Examples.Text.NER


+ 1
- 0
test/TensorFlowNET.Examples/TextProcessing/Word2Vec.cs View File

@@ -6,6 +6,7 @@ using System.Linq;
using Tensorflow; using Tensorflow;
using TensorFlowNET.Examples.Utility; using TensorFlowNET.Examples.Utility;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples namespace TensorFlowNET.Examples
{ {


+ 1
- 0
test/TensorFlowNET.Examples/TextProcessing/cnn_models/CharCnn.cs View File

@@ -1,5 +1,6 @@
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples.Text namespace TensorFlowNET.Examples.Text
{ {


+ 2
- 1
test/TensorFlowNET.Examples/TextProcessing/cnn_models/VdCnn.cs View File

@@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples.Text namespace TensorFlowNET.Examples.Text
{ {
@@ -32,7 +33,7 @@ namespace TensorFlowNET.Examples.Text
num_filters = new int[] { 64, 64, 128, 256, 512 }; num_filters = new int[] { 64, 64, 128, 256, 512 };
num_blocks = new int[] { 2, 2, 2, 2 }; num_blocks = new int[] { 2, 2, 2, 2 };
learning_rate = 0.001f; 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); fc_initializer = tf.truncated_normal_initializer(stddev: 0.05f);


x = tf.placeholder(tf.int32, new TensorShape(-1, document_max_len), name: "x"); x = tf.placeholder(tf.int32, new TensorShape(-1, document_max_len), name: "x");


+ 1
- 0
test/TensorFlowNET.Examples/TextProcessing/cnn_models/WordCnn.cs View File

@@ -17,6 +17,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.Examples.Text namespace TensorFlowNET.Examples.Text
{ {


+ 1
- 1
test/TensorFlowNET.UnitTest/Basics/AssignTests.cs View File

@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest.Basics namespace TensorFlowNET.UnitTest.Basics
{ {


+ 1
- 1
test/TensorFlowNET.UnitTest/Basics/NegativeTests.cs View File

@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest.Basics namespace TensorFlowNET.UnitTest.Basics
{ {


+ 1
- 1
test/TensorFlowNET.UnitTest/ConstantTest.cs View File

@@ -4,7 +4,7 @@ using System;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/ConsumersTest.cs View File

@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs View File

@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using TensorFlowNET.Examples; using TensorFlowNET.Examples;
using static Tensorflow.Binding;
namespace TensorFlowNET.ExamplesTests namespace TensorFlowNET.ExamplesTests
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/GradientTest.cs View File

@@ -3,6 +3,7 @@ using NumSharp;
using System.Linq; using System.Linq;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 1
test/TensorFlowNET.UnitTest/GraphTest.cs View File

@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Tensorflow; using Tensorflow;
using Buffer = Tensorflow.Buffer; using Buffer = Tensorflow.Buffer;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/KerasTests.cs View File

@@ -2,6 +2,7 @@
using Keras.Layers; using Keras.Layers;
using NumSharp; using NumSharp;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/NameScopeTest.cs View File

@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/OperationsTest.cs View File

@@ -5,6 +5,7 @@ using System.Linq;
using NumSharp; using NumSharp;
using Tensorflow; using Tensorflow;
using Buffer = Tensorflow.Buffer; using Buffer = Tensorflow.Buffer;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 1
test/TensorFlowNET.UnitTest/PlaceholderTest.cs View File

@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 2
test/TensorFlowNET.UnitTest/PythonTest.cs View File

@@ -5,8 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NumSharp; using NumSharp;
using Tensorflow; using Tensorflow;
using Tensorflow.Util;
using static Tensorflow.Python;
using static Tensorflow.Binding;
namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 1
test/TensorFlowNET.UnitTest/SessionTest.cs View File

@@ -3,7 +3,7 @@ using NumSharp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/TensorTest.cs View File

@@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 1
- 0
test/TensorFlowNET.UnitTest/TrainSaverTest.cs View File

@@ -2,6 +2,7 @@
using System; using System;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


+ 2
- 1
test/TensorFlowNET.UnitTest/VariableTest.cs View File

@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using static Tensorflow.Python; using static Tensorflow.Python;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {
@@ -28,7 +29,7 @@ namespace TensorFlowNET.UnitTest
} }


/// <summary> /// <summary>
/// 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 /// how to create a new variable
/// </summary> /// </summary>
[TestMethod] [TestMethod]


+ 1
- 0
test/TensorFlowNET.UnitTest/VersionTest.cs View File

@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Tensorflow; using Tensorflow;
using static Tensorflow.Binding;


namespace TensorFlowNET.UnitTest namespace TensorFlowNET.UnitTest
{ {


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save