diff --git a/src/TensorFlowNET.Core/APIs/tf.distributions.cs b/src/TensorFlowNET.Core/APIs/tf.distributions.cs index 884ee926..fec6626a 100644 --- a/src/TensorFlowNET.Core/APIs/tf.distributions.cs +++ b/src/TensorFlowNET.Core/APIs/tf.distributions.cs @@ -2,13 +2,17 @@ using System.Collections.Generic; using System.Text; -namespace Tensorflow.APIs +namespace Tensorflow { public static partial class tf { public static class distributions { - public static Normal(Tensor loc, Tensor scale, bool validate_args = false, bool allow_nan_stats = true, string name = "Normal") => Normal(loc, scale, validate_args = false, allow_nan_stats = true, "Normal"); + public static Normal Normal(Tensor loc, + Tensor scale, + bool validate_args = false, + bool allow_nan_stats = true, + string name = "Normal") => new Normal(loc, scale, validate_args = false, allow_nan_stats = true, "Normal"); } } } diff --git a/src/TensorFlowNET.Core/APIs/tf.layers.cs b/src/TensorFlowNET.Core/APIs/tf.layers.cs index b93afd68..0b17ca83 100644 --- a/src/TensorFlowNET.Core/APIs/tf.layers.cs +++ b/src/TensorFlowNET.Core/APIs/tf.layers.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Text; -using Tensorflow.Layers; +using Tensorflow.Keras.Layers; using Tensorflow.Operations.Activation; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.math.cs b/src/TensorFlowNET.Core/APIs/tf.math.cs index bbd4b7eb..9226ce63 100644 --- a/src/TensorFlowNET.Core/APIs/tf.math.cs +++ b/src/TensorFlowNET.Core/APIs/tf.math.cs @@ -10,6 +10,8 @@ namespace Tensorflow public static Tensor sub(Tensor a, Tensor b) => gen_math_ops.sub(a, b); + public static Tensor sqrt(Tensor a, string name = null) => gen_math_ops.sqrt(a, name); + public static Tensor subtract(Tensor x, T[] y, string name = null) where T : struct => gen_math_ops.sub(x, ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y"), name); diff --git a/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs b/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs index b2c220a7..2ac90fc8 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs @@ -7,7 +7,7 @@ using System.Text; namespace Tensorflow { - class _BaseDistribution : Python + public class _BaseDistribution : Python { // Abstract base class needed for resolving subclass hierarchy. } @@ -17,10 +17,10 @@ namespace Tensorflow /// Distribution is a base class for constructing and organizing properties /// (e.g., mean, variance) of random variables (e.g, Bernoulli, Gaussian). /// - class Distribution : _BaseDistribution + public class Distribution : _BaseDistribution { public TF_DataType _dtype {get;set;} - public static ReparameterizationType _reparameterization_type {get;set;} + //public ReparameterizationType _reparameterization_type {get;set;} public bool _validate_args {get;set;} public bool _allow_nan_stats {get;set;} public Dictionary _parameters {get;set;} diff --git a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs index d5b44b06..2c1caa27 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs @@ -3,7 +3,7 @@ using Tensorflow; namespace Tensorflow { - class Normal : Distribution + public class Normal : Distribution { public Tensor _loc { get; set; } public Tensor _scale { get; set; } @@ -25,7 +25,7 @@ namespace Tensorflow /// /// /// - Normal (Tensor loc, Tensor scale, bool validate_args=false, bool allow_nan_stats=true, string name="Normal") + public Normal (Tensor loc, Tensor scale, bool validate_args=false, bool allow_nan_stats=true, string name="Normal") { parameters.Add("name", name); parameters.Add("loc", loc); diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index 0ef8540c..e3b8022a 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -62,6 +62,13 @@ namespace Tensorflow return _op.outputs[0]; } + public static Tensor sqrt(Tensor x, string name = null) + { + var _op = _op_def_lib._apply_op_helper("Sqrt", name, args: new { x }); + + return _op.outputs[0]; + } + public static Tensor sub(Tx x, Ty y, string name = null) { var _op = _op_def_lib._apply_op_helper("Sub", name, args: new { x, y }); diff --git a/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs b/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs index 00cd1211..05b7c0f2 100644 --- a/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs +++ b/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs @@ -74,7 +74,7 @@ namespace TensorFlowNET.Examples // Create a 3x2 univariate normal distribution with the // Known mean and variance - var dist = tf.distributions.Normal(loc=mean, scale=tf.sqrt(variance)); + var dist = tf.distributions.Normal(mean, tf.sqrt(variance)); }