Skip to content

Commit d5d5a46

Browse files
committed
fix bug in normal distribution: _log_prob
1 parent 1318945 commit d5d5a46

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

TensorFlow.NET.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.28803.452
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.168
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.UnitTest", "test\TensorFlowNET.UnitTest\TensorFlowNET.UnitTest.csproj", "{029A8CF1-CF95-4DCB-98AA-9D3D96A83B3E}"
77
EndProject
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Keras.UnitTest", "test\Kera
1717
EndProject
1818
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "TensorFlowNET.Examples.FSharp", "test\TensorFlowNET.Examples.FSharp\TensorFlowNET.Examples.FSharp.fsproj", "{62BC3801-F0D3-44A9-A0AC-712F40C8F961}"
1919
EndProject
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NumSharp.Core", "..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj", "{E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
5153
{62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Debug|Any CPU.Build.0 = Debug|Any CPU
5254
{62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Release|Any CPU.ActiveCfg = Release|Any CPU
5355
{62BC3801-F0D3-44A9-A0AC-712F40C8F961}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{E038A3C1-9055-4BF4-BE5B-0E7D661A7EB3}.Release|Any CPU.Build.0 = Release|Any CPU
5460
EndGlobalSection
5561
GlobalSection(SolutionProperties) = preSolution
5662
HideSolutionNode = FALSE

src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public Tensor _batch_shape()
8282

8383
protected override Tensor _log_prob(Tensor x)
8484
{
85-
var log_prob = _log_unnormalized_prob(_z(x));
85+
var log_prob = _log_unnormalized_prob(x);
8686
var log_norm = _log_normalization();
8787
return tf.sub(log_prob, log_norm);
8888
}

src/TensorFlowNET.Core/TensorFlowNET.Core.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,14 @@ Docs: https://tensorflownet.readthedocs.io</Description>
6262
<Folder Include="Keras\Initializers\" />
6363
</ItemGroup>
6464

65+
<ItemGroup>
66+
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
67+
</ItemGroup>
68+
69+
<ItemGroup>
70+
<Reference Include="NumSharp.Core">
71+
<HintPath>..\..\..\..\NumSharp\src\NumSharp.Core\bin\Debug\netstandard2.0\NumSharp.Core.dll</HintPath>
72+
</Reference>
73+
</ItemGroup>
74+
6575
</Project>

test/TensorFlowNET.Examples/BasicModels/NaiveBayesClassifier.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public bool Run()
3434
var (xx, yy) = np.meshgrid(np.linspace(x_min, x_max, 30), np.linspace(y_min, y_max, 30));
3535
with(tf.Session(), sess =>
3636
{
37-
var samples = np.hstack<float>(xx.ravel().reshape(xx.size, 1), yy.ravel().reshape(yy.size, 1));
37+
var samples = np.vstack<float>(xx.ravel(), yy.ravel());
38+
samples = np.transpose(samples);
39+
var array = np.Load<double[,]>("H:\\PythonApplication1\\PythonApplication1\\data.npy");
40+
samples = np.array(array).astype(np.float32);
3841
var Z = sess.run(predict(samples));
3942
});
4043

test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@
2323
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" />
2424
</ItemGroup>
2525

26+
<ItemGroup>
27+
<Reference Include="NumSharp.Core">
28+
<HintPath>..\..\..\..\NumSharp\src\NumSharp.Core\bin\Debug\netstandard2.0\NumSharp.Core.dll</HintPath>
29+
</Reference>
30+
</ItemGroup>
31+
2632
</Project>

0 commit comments

Comments
 (0)