Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions TensorFlow.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Utility", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Visualization", "TensorFlowNET.Visualization\TensorFlowNET.Visualization.csproj", "{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NumSharp.Core", "..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj", "{0AB4662E-7E3C-455F-BF0C-23D56CBE74F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -41,10 +39,6 @@ Global
{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BB2ABD1-635E-41E4-B534-CB5B6A2D754D}.Release|Any CPU.Build.0 = Release|Any CPU
{0AB4662E-7E3C-455F-BF0C-23D56CBE74F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AB4662E-7E3C-455F-BF0C-23D56CBE74F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AB4662E-7E3C-455F-BF0C-23D56CBE74F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AB4662E-7E3C-455F-BF0C-23D56CBE74F3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 11 additions & 0 deletions src/TensorFlowNET.Core/APIs/tf.nn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow
{
public static partial class tf
{
public static nn_impl nn => new nn_impl();
}
}
29 changes: 29 additions & 0 deletions src/TensorFlowNET.Core/Operations/math_ops.py.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,35 @@ public static Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, s
return x;
});
}
/// <summary>
///
/// </summary>
/// <param name="input_tensor"></param>
/// <param name="axes"></param>
/// <param name="keepdims"></param>
/// <param name="name"></param>
public static Tensor reduce_mean(Tensor input_tensor, int[] axes = null, bool keepdims = false, string name = null)
{
throw new NotFiniteNumberException();
}
/// <summary>
/// Reduction Operation
/// </summary>
/// <param name="x"></param>
/// <param name="axis"></param>
/// <param name="reduction_indices"></param>
public void _ReductionDims(Tensor x, int[] axis, int[] reduction_indices = null)
{
if (reduction_indices != null || reduction_indices.Length != 0)
{
if (axis != null)
{

}
}

throw new NotSupportedException("Can't specify both axis' and 'reduction_indices'.");
}

/// <summary>
/// Helper function for reduction ops.
Expand Down
32 changes: 32 additions & 0 deletions src/TensorFlowNET.Core/Operations/nn_impl.py.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow
{
public class nn_impl : Python
{
/// <summary>
/// Calculate the mean and variance of `x`
/// </summary>
/// <param name="x"></param>
/// <param name="axes"></param>
/// <param name="name"></param>
/// <param name="keep_dims"></param>
/// <returns></returns>
public (Tensor, Tensor) moments(Tensor x,
int[] axes,
string name = null,
bool keep_dims = false)
{
with<ops.name_scope>(new ops.name_scope(name, "moments", new { x, axes }), scope =>
{
var y = math_ops.cast(x, TF_DataType.TF_FLOAT);
// mean = math_ops.reduce_mean(y, axes, keepdims = True, name = "mean")

});

throw new NotImplementedException("");
}
}
}
4 changes: 0 additions & 4 deletions src/TensorFlowNET.Core/TensorFlowNET.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,4 @@ Docs: https://tensorflownet.readthedocs.io</Description>
<Content CopyToOutputDirectory="PreserveNewest" Include="./runtimes/win-x64/native/tensorflow.dll" Link="tensorflow.dll" Pack="true" PackagePath="runtimes/win-x64/native/tensorflow.dll" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
</ItemGroup>

</Project>
24 changes: 22 additions & 2 deletions test/TensorFlowNET.Examples/NaiveBayesClassifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@
using System.Collections.Generic;
using System.Text;
using Tensorflow;
using NumSharp.Core;
using System.Linq;

namespace TensorFlowNET.Examples
{
/// <summary>
/// https://github.com/nicolov/naive_bayes_tensorflow
/// </summary>
public class NaiveBayesClassifier : Python, IExample
{
{
public void Run()
{
throw new NotImplementedException();
// t/f.nn.moments()
}

public void fit(NDArray X, NDArray y)
{
// separate training points by class
// shape : nb_class * nb_samples * nb_features
NDArray unique_y = y.unique<long>();
NDArray points_by_class = np.array(y.Data<long>().Where(ys => unique_y.Data<long>().Contains(ys)));

foreach (long cls in unique_y)
{

}


// estimate mean and variance for each class / feature
// shape : nb_classes * nb_features

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj" />
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" />
<ProjectReference Include="..\..\src\TensorFlowNET.Utility\TensorFlowNET.Utility.csproj" />
</ItemGroup>
Expand Down