From d5d5a46ba358afbdef98ca501b6745e64d1d7571 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Thu, 20 Jun 2019 11:01:51 -0500 Subject: [PATCH] fix bug in normal distribution: _log_prob --- TensorFlow.NET.sln | 10 ++++++++-- .../Operations/Distributions/normal.py.cs | 2 +- src/TensorFlowNET.Core/TensorFlowNET.Core.csproj | 10 ++++++++++ .../BasicModels/NaiveBayesClassifier.cs | 5 ++++- .../TensorFlowNET.Examples.csproj | 6 ++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/TensorFlow.NET.sln b/TensorFlow.NET.sln index 51125309..29ecf84b 100644 --- a/TensorFlow.NET.sln +++ b/TensorFlow.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.452 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.168 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.UnitTest", "test\TensorFlowNET.UnitTest\TensorFlowNET.UnitTest.csproj", "{029A8CF1-CF95-4DCB-98AA-9D3D96A83B3E}" EndProject @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Keras.UnitTest", "test\Kera EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TensorFlowNET.Examples.FSharp", "test\TensorFlowNET.Examples.FSharp\TensorFlowNET.Examples.FSharp.fsproj", "{62BC3801-F0D3-44A9-A0AC-712F40C8F961}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NumSharp.Core", "..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj", "{E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,6 +53,10 @@ Global {62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Debug|Any CPU.Build.0 = Debug|Any CPU {62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Release|Any CPU.ActiveCfg = Release|Any CPU {62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Release|Any CPU.Build.0 = Release|Any CPU + {E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs index 4c69faba..29cefda1 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs @@ -82,7 +82,7 @@ namespace Tensorflow protected override Tensor _log_prob(Tensor x) { - var log_prob = _log_unnormalized_prob(_z(x)); + var log_prob = _log_unnormalized_prob(x); var log_norm = _log_normalization(); return tf.sub(log_prob, log_norm); } diff --git a/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj b/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj index 1cca840f..71ae49c0 100644 --- a/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj +++ b/src/TensorFlowNET.Core/TensorFlowNET.Core.csproj @@ -62,4 +62,14 @@ Docs: https://tensorflownet.readthedocs.io + + + + + + + ..\..\..\..\NumSharp\src\NumSharp.Core\bin\Debug\netstandard2.0\NumSharp.Core.dll + + + diff --git a/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs b/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs index e1615035..9555bcbc 100644 --- a/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs +++ b/test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs @@ -34,7 +34,10 @@ namespace TensorFlowNET.Examples var (xx, yy) = np.meshgrid(np.linspace(x_min, x_max, 30), np.linspace(y_min, y_max, 30)); with(tf.Session(), sess => { - var samples = np.hstack(xx.ravel().reshape(xx.size, 1), yy.ravel().reshape(yy.size, 1)); + var samples = np.vstack(xx.ravel(), yy.ravel()); + samples = np.transpose(samples); + var array = np.Load("H:\\PythonApplication1\\PythonApplication1\\data.npy"); + samples = np.array(array).astype(np.float32); var Z = sess.run(predict(samples)); }); diff --git a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj index f6cbea99..e64e6df8 100644 --- a/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj +++ b/test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj @@ -23,4 +23,10 @@ + + + ..\..\..\..\NumSharp\src\NumSharp.Core\bin\Debug\netstandard2.0\NumSharp.Core.dll + + +