@@ -0,0 +1,20 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<None Remove="tensorflow.dll" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,23 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | |||||
<StartupObject>Keras.Example.Program</StartupObject> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Colorful.Console" Version="1.2.9" /> | |||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | |||||
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.14.0" /> | |||||
<PackageReference Include="SharpZipLib" Version="1.1.0" /> | |||||
<PackageReference Include="System.Drawing.Common" Version="4.5.1" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | |||||
<ProjectReference Include="..\..\src\KerasNET.Core\Keras.Core.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,61 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Tensorflow; | |||||
using Keras.Layers; | |||||
using NumSharp; | |||||
namespace Keras.Example | |||||
{ | |||||
class Program | |||||
{ | |||||
static void Main(string[] args) | |||||
{ | |||||
Console.WriteLine("================================== Keras =================================="); | |||||
#region data | |||||
var batch_size = 1000; | |||||
var (X, Y) = XOR(batch_size); | |||||
//var (X, Y, batch_size) = (np.array(new float[,]{{1, 0 },{1, 1 },{0, 0 },{0, 1 }}), np.array(new int[] { 0, 1, 1, 0 }), 4); | |||||
#endregion | |||||
#region features | |||||
var (features, labels) = (new Tensor(X), new Tensor(Y)); | |||||
var num_steps = 10000; | |||||
#endregion | |||||
#region model | |||||
var m = new Model(); | |||||
//m.Add(new Dense(8, name: "Hidden", activation: tf.nn.relu())).Add(new Dense(1, name:"Output")); | |||||
m.Add( | |||||
new ILayer[] { | |||||
new Dense(8, name: "Hidden_1", activation: tf.nn.relu()), | |||||
new Dense(1, name: "Output") | |||||
}); | |||||
m.train(num_steps, (X, Y)); | |||||
#endregion | |||||
Console.ReadKey(); | |||||
} | |||||
static (NDArray, NDArray) XOR(int samples) | |||||
{ | |||||
var X = new List<float[]>(); | |||||
var Y = new List<float>(); | |||||
var r = new Random(); | |||||
for (int i = 0; i < samples; i++) | |||||
{ | |||||
var x1 = (float)r.Next(0, 2); | |||||
var x2 = (float)r.Next(0, 2); | |||||
var y = 0.0f; | |||||
if (x1 == x2) | |||||
y = 1.0f; | |||||
X.Add(new float[] { x1, x2 }); | |||||
Y.Add(y); | |||||
} | |||||
return (np.array(X.ToArray()), np.array(Y.ToArray())); | |||||
} | |||||
} | |||||
} |
@@ -1,10 +0,0 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<packages> | |||||
<package id="ArrayFire" version="0.0.2" targetFramework="net472" /> | |||||
<package id="Google.Protobuf" version="3.7.0" targetFramework="net472" /> | |||||
<package id="NumSharp" version="0.10.1" targetFramework="net472" /> | |||||
<package id="System.Buffers" version="4.4.0" targetFramework="net472" /> | |||||
<package id="System.Memory" version="4.5.2" targetFramework="net472" /> | |||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" /> | |||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" /> | |||||
</packages> |
@@ -1,40 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||||
<IsPackable>false</IsPackable> | |||||
<AssemblyName>Keras.UnitTest</AssemblyName> | |||||
<RootNamespace>Keras.UnitTest</RootNamespace> | |||||
<ApplicationIcon /> | |||||
<OutputType>Exe</OutputType> | |||||
<StartupObject /> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | |||||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||||
</PropertyGroup> | |||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | |||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> | |||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> | |||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> | |||||
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.14.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\src\KerasNET.Core\Keras.Core.csproj" /> | |||||
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -1,26 +0,0 @@ | |||||
using Tensorflow; | |||||
using Keras.Layers; | |||||
using NumSharp; | |||||
using Microsoft.VisualStudio.TestTools.UnitTesting; | |||||
namespace Keras.Test | |||||
{ | |||||
[TestClass] | |||||
public class BaseTests | |||||
{ | |||||
[TestMethod] | |||||
public void Dense_Tensor_ShapeTest() | |||||
{ | |||||
var dense_1 = new Dense(1, name: "dense_1", activation: tf.nn.relu()); | |||||
var input = new Tensor(np.array(new int[] { 3 })); | |||||
dense_1.__build__(input.TensorShape); | |||||
var outputShape = dense_1.output_shape(input.TensorShape); | |||||
var a = (int[])(outputShape.Dimensions); | |||||
var b = (int[])(new int[] { 1 }); | |||||
var _a = np.array(a); | |||||
var _b = np.array(b); | |||||
Assert.IsTrue(np.array_equal(_a, _b)); | |||||
} | |||||
} | |||||
} |
@@ -1,11 +0,0 @@ | |||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<packages> | |||||
<package id="ArrayFire" version="0.0.2" targetFramework="net472" /> | |||||
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net472" /> | |||||
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net472" /> | |||||
<package id="NumSharp" version="0.10.1" targetFramework="net472" /> | |||||
<package id="System.Buffers" version="4.4.0" targetFramework="net472" /> | |||||
<package id="System.Memory" version="4.5.2" targetFramework="net472" /> | |||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" /> | |||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" /> | |||||
</packages> |
@@ -1,12 +0,0 @@ | |||||
using System; | |||||
namespace TensorFlowHub.Examples | |||||
{ | |||||
class Program | |||||
{ | |||||
static void Main(string[] args) | |||||
{ | |||||
Console.WriteLine("Hello World!"); | |||||
} | |||||
} | |||||
} |
@@ -1,16 +0,0 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<OutputType>Exe</OutputType> | |||||
<TargetFramework>netcoreapp2.2</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="1.14.0" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<ProjectReference Include="..\..\src\TensorFlowHub\TensorFlowHub.csproj" /> | |||||
</ItemGroup> | |||||
</Project> |