| @@ -1,7 +1,7 @@ | |||
| | |||
| Microsoft Visual Studio Solution File, Format Version 12.00 | |||
| # Visual Studio Version 16 | |||
| VisualStudioVersion = 16.0.28803.156 | |||
| # 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 | |||
| @@ -9,6 +9,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Examples", "t | |||
| EndProject | |||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Core", "src\TensorFlowNET.Core\TensorFlowNET.Core.csproj", "{FD682AC0-7B2D-45D3-8B0D-C6D678B04144}" | |||
| EndProject | |||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MakinaNET.Core", "src\MakinaNET.Core\MakinaNET.Core.csproj", "{6FF518EB-523F-4930-919E-05011EFCED6F}" | |||
| EndProject | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakinaNET.Example", "src\MakinaNET.Example\MakinaNET.Example.csproj", "{17E1AC16-9E0E-4545-905A-E92C6300C7AF}" | |||
| EndProject | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakinaNET.UnitTest", "src\MakinaNET.Test\MakinaNET.UnitTest.csproj", "{02F54D9F-617B-4B15-9D21-E21AF66693B1}" | |||
| EndProject | |||
| Global | |||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
| Debug|Any CPU = Debug|Any CPU | |||
| @@ -27,6 +33,18 @@ Global | |||
| {FD682AC0-7B2D-45D3-8B0D-C6D678B04144}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {FD682AC0-7B2D-45D3-8B0D-C6D678B04144}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {FD682AC0-7B2D-45D3-8B0D-C6D678B04144}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {6FF518EB-523F-4930-919E-05011EFCED6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {6FF518EB-523F-4930-919E-05011EFCED6F}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {6FF518EB-523F-4930-919E-05011EFCED6F}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {6FF518EB-523F-4930-919E-05011EFCED6F}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {17E1AC16-9E0E-4545-905A-E92C6300C7AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {17E1AC16-9E0E-4545-905A-E92C6300C7AF}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {17E1AC16-9E0E-4545-905A-E92C6300C7AF}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {17E1AC16-9E0E-4545-905A-E92C6300C7AF}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {02F54D9F-617B-4B15-9D21-E21AF66693B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {02F54D9F-617B-4B15-9D21-E21AF66693B1}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {02F54D9F-617B-4B15-9D21-E21AF66693B1}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {02F54D9F-617B-4B15-9D21-E21AF66693B1}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| EndGlobalSection | |||
| GlobalSection(SolutionProperties) = preSolution | |||
| HideSolutionNode = FALSE | |||
| @@ -0,0 +1,15 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using Tensorflow; | |||
| namespace Makina | |||
| { | |||
| public static class Makina | |||
| { | |||
| public static Tensor create_tensor(int[] shape, float mean = 0, float stddev = 1, TF_DataType dtype = TF_DataType.TF_FLOAT, int? seed = null, string name = null) | |||
| { | |||
| return tf.truncated_normal(shape: shape, mean: mean, stddev: stddev, dtype: dtype, seed: seed, name: name); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| namespace Makina | |||
| { | |||
| interface IInitializer | |||
| { | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using Tensorflow; | |||
| using Tensorflow.Layers; | |||
| namespace Makina.Initializer | |||
| { | |||
| class BaseInitializer : IInitializer | |||
| { | |||
| public int seed; | |||
| } | |||
| } | |||
| @@ -0,0 +1,57 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using System.Linq; | |||
| using Tensorflow; | |||
| using static Makina.Makina; | |||
| using Makina; | |||
| using NumSharp; | |||
| using Tensorflow.Operations.Activation; | |||
| namespace Makina.Layers | |||
| { | |||
| public class Dense : ILayer | |||
| { | |||
| RefVariable W; | |||
| int units; | |||
| TensorShape WShape; | |||
| string name; | |||
| IActivation activation; | |||
| public Dense(int units, string name = null, IActivation activation = null) | |||
| { | |||
| this.activation = activation; | |||
| this.units = units; | |||
| this.name = (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))?this.GetType().Name + "_" + this.GetType().GUID:name; | |||
| } | |||
| public ILayer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f) | |||
| { | |||
| Console.WriteLine("Building Layer \"" + name + "\" ..."); | |||
| if (stddev == -1) | |||
| stddev = (float)(1 / Math.Sqrt(2)); | |||
| var dim = input_shape.Dimensions; | |||
| var input_dim = dim[dim.Length - 1]; | |||
| W = tf.Variable(create_tensor(new int[] { input_dim, units }, seed: seed, stddev: (float)stddev)); | |||
| WShape = new TensorShape(W.shape); | |||
| return this; | |||
| } | |||
| public Tensor __call__(Tensor x) | |||
| { | |||
| var dot = tf.matmul(x, W); | |||
| if (this.activation != null) | |||
| dot = activation.Activate(dot); | |||
| Console.WriteLine("Calling Layer \"" + name + "(" + np.array(dot.getShape().Dimensions).ToString() + ")\" ..."); | |||
| return dot; | |||
| } | |||
| public TensorShape __shape__() | |||
| { | |||
| return WShape; | |||
| } | |||
| public TensorShape output_shape(TensorShape input_shape) | |||
| { | |||
| var output_shape = input_shape.Dimensions; | |||
| output_shape[output_shape.Length - 1] = units; | |||
| return new TensorShape(output_shape); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,16 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using Tensorflow; | |||
| using NumSharp; | |||
| namespace Makina.Layers | |||
| { | |||
| public interface ILayer | |||
| { | |||
| TensorShape __shape__(); | |||
| ILayer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f); | |||
| Tensor __call__(Tensor x); | |||
| TensorShape output_shape(TensorShape input_shape); | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
| <PropertyGroup> | |||
| <TargetFramework>netstandard2.0</TargetFramework> | |||
| <AssemblyName>Makina</AssemblyName> | |||
| <RootNamespace>Makina</RootNamespace> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="..\TensorFlowNET.Core\TensorFlowNET.Core.csproj" /> | |||
| </ItemGroup> | |||
| </Project> | |||
| @@ -0,0 +1,127 @@ | |||
| using Makina.Layers; | |||
| using NumSharp; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Text; | |||
| using Tensorflow; | |||
| using static Makina.Makina; | |||
| using static Tensorflow.Python; | |||
| namespace Makina | |||
| { | |||
| public class Model | |||
| { | |||
| public Tensor Flow; | |||
| List<ILayer> layer_stack; | |||
| public TensorShape InputShape; | |||
| public Model() | |||
| { | |||
| layer_stack = new List<ILayer>(); | |||
| } | |||
| public Model Add(ILayer layer) | |||
| { | |||
| layer_stack.Add(layer); | |||
| return this; | |||
| } | |||
| public Model Add(IEnumerable<ILayer> layers) | |||
| { | |||
| layer_stack.AddRange(layers); | |||
| return this; | |||
| } | |||
| public Tensor getFlow() | |||
| { | |||
| try | |||
| { | |||
| return Flow; | |||
| } | |||
| catch (Exception ex) | |||
| { | |||
| return null; | |||
| } | |||
| } | |||
| public (Operation, Tensor, Tensor) make_graph(Tensor features, Tensor labels) | |||
| { | |||
| // TODO : Creating Loss Functions And Optimizers..... | |||
| #region Model Layers Graph | |||
| /* | |||
| var stddev = 1 / Math.Sqrt(2); | |||
| var d1 = new Dense(num_hidden); | |||
| d1.__build__(features.getShape()); | |||
| var hidden_activations = tf.nn.relu(d1.__call__(features)); | |||
| var d1_output = d1.output_shape(features.getShape()); | |||
| var d2 = new Dense(1); | |||
| d2.__build__(d1.output_shape(features.getShape()), seed: 17, stddev: (float)(1/ Math.Sqrt(num_hidden))); | |||
| var logits = d2.__call__(hidden_activations); | |||
| var predictions = tf.sigmoid(tf.squeeze(logits)); | |||
| */ | |||
| #endregion | |||
| #region Model Graph Form Layer Stack | |||
| var flow_shape = features.getShape(); | |||
| Flow = features; | |||
| for (int i = 0; i < layer_stack.Count; i++) | |||
| { | |||
| layer_stack[i].__build__(flow_shape); | |||
| flow_shape = layer_stack[i].output_shape(flow_shape); | |||
| Flow = layer_stack[i].__call__(Flow); | |||
| } | |||
| var predictions = tf.sigmoid(tf.squeeze(Flow)); | |||
| #endregion | |||
| #region loss and optimizer | |||
| var loss = tf.reduce_mean(tf.square(predictions - tf.cast(labels, tf.float32)), name: "loss"); | |||
| var gs = tf.Variable(0, trainable: false, name: "global_step"); | |||
| var train_op = tf.train.GradientDescentOptimizer(0.2f).minimize(loss, global_step: gs); | |||
| #endregion | |||
| return (train_op, loss, gs); | |||
| } | |||
| public float train(int num_steps, (NDArray, NDArray) training_dataset) | |||
| { | |||
| var (X, Y) = training_dataset; | |||
| var x_shape = X.shape; | |||
| var batch_size = x_shape[0]; | |||
| var graph = tf.Graph().as_default(); | |||
| var features = tf.placeholder(tf.float32, new TensorShape(batch_size, 2)); | |||
| var labels = tf.placeholder(tf.float32, new TensorShape(batch_size)); | |||
| var (train_op, loss, gs) = this.make_graph(features, labels); | |||
| var init = tf.global_variables_initializer(); | |||
| float loss_value = 0; | |||
| with(tf.Session(graph), sess => | |||
| { | |||
| sess.run(init); | |||
| var step = 0; | |||
| while (step < num_steps) | |||
| { | |||
| var result = sess.run( | |||
| new ITensorOrOperation[] { train_op, gs, loss }, | |||
| new FeedItem(features, X), | |||
| new FeedItem(labels, Y)); | |||
| loss_value = result[2]; | |||
| step = result[1]; | |||
| if (step % 1000 == 0) | |||
| Console.WriteLine($"Step {step} loss: {loss_value}"); | |||
| } | |||
| Console.WriteLine($"Final loss: {loss_value}"); | |||
| }); | |||
| return loss_value; | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <configuration> | |||
| <startup> | |||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | |||
| </startup> | |||
| <runtime> | |||
| <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |||
| <dependentAssembly> | |||
| <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | |||
| <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> | |||
| </dependentAssembly> | |||
| </assemblyBinding> | |||
| </runtime> | |||
| </configuration> | |||
| @@ -0,0 +1,87 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| <ProjectGuid>{17E1AC16-9E0E-4545-905A-E92C6300C7AF}</ProjectGuid> | |||
| <OutputType>Exe</OutputType> | |||
| <RootNamespace>Makina.Example</RootNamespace> | |||
| <AssemblyName>Makina.Example</AssemblyName> | |||
| <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | |||
| <FileAlignment>512</FileAlignment> | |||
| <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |||
| <Deterministic>true</Deterministic> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| <PlatformTarget>AnyCPU</PlatformTarget> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| <DebugType>full</DebugType> | |||
| <Optimize>false</Optimize> | |||
| <OutputPath>bin\Debug\</OutputPath> | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| <Prefer32Bit>false</Prefer32Bit> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| <PlatformTarget>AnyCPU</PlatformTarget> | |||
| <DebugType>pdbonly</DebugType> | |||
| <Optimize>true</Optimize> | |||
| <OutputPath>bin\Release\</OutputPath> | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="ArrayFire, Version=0.0.2.0, Culture=neutral, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\ArrayFire.0.0.2\lib\netstandard2.0\ArrayFire.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="Google.Protobuf, Version=3.7.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\Google.Protobuf.3.7.0\lib\net45\Google.Protobuf.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="NumSharp.Core, Version=0.10.0.0, Culture=neutral, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\NumSharp.0.10.0\lib\netstandard2.0\NumSharp.Core.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System" /> | |||
| <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Core" /> | |||
| <Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Numerics" /> | |||
| <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Xml.Linq" /> | |||
| <Reference Include="System.Data.DataSetExtensions" /> | |||
| <Reference Include="Microsoft.CSharp" /> | |||
| <Reference Include="System.Data" /> | |||
| <Reference Include="System.Net.Http" /> | |||
| <Reference Include="System.Xml" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Compile Include="Program.cs" /> | |||
| <Compile Include="Properties\AssemblyInfo.cs" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Include="App.config" /> | |||
| <None Include="packages.config" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="..\MakinaNET.Core\MakinaNET.Core.csproj"> | |||
| <Project>{6ff518eb-523f-4930-919e-05011efced6f}</Project> | |||
| <Name>MakinaNET.Core</Name> | |||
| </ProjectReference> | |||
| <ProjectReference Include="..\TensorFlowNET.Core\TensorFlowNET.Core.csproj"> | |||
| <Project>{fd682ac0-7b2d-45d3-8b0d-c6d678b04144}</Project> | |||
| <Name>TensorFlowNET.Core</Name> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
| </Project> | |||
| @@ -0,0 +1,67 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using Tensorflow; | |||
| using static Tensorflow.Python; | |||
| using static Makina.Makina; | |||
| using Makina.Layers; | |||
| using Makina; | |||
| using NumSharp; | |||
| namespace Makina.Example | |||
| { | |||
| class Program | |||
| { | |||
| static void Main(string[] args) | |||
| { | |||
| Console.WriteLine("================================== Makina =================================="); | |||
| #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())); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| using System.Reflection; | |||
| using System.Runtime.CompilerServices; | |||
| using System.Runtime.InteropServices; | |||
| // General Information about an assembly is controlled through the following | |||
| // set of attributes. Change these attribute values to modify the information | |||
| // associated with an assembly. | |||
| [assembly: AssemblyTitle("Makina.Example")] | |||
| [assembly: AssemblyDescription("")] | |||
| [assembly: AssemblyConfiguration("")] | |||
| [assembly: AssemblyCompany("")] | |||
| [assembly: AssemblyProduct("Makina.Example")] | |||
| [assembly: AssemblyCopyright("Copyright © 2019")] | |||
| [assembly: AssemblyTrademark("")] | |||
| [assembly: AssemblyCulture("")] | |||
| // Setting ComVisible to false makes the types in this assembly not visible | |||
| // to COM components. If you need to access a type in this assembly from | |||
| // COM, set the ComVisible attribute to true on that type. | |||
| [assembly: ComVisible(false)] | |||
| // The following GUID is for the ID of the typelib if this project is exposed to COM | |||
| [assembly: Guid("17e1ac16-9e0e-4545-905a-e92c6300c7af")] | |||
| // Version information for an assembly consists of the following four values: | |||
| // | |||
| // Major Version | |||
| // Minor Version | |||
| // Build Number | |||
| // Revision | |||
| // | |||
| // You can specify all the values or you can default the Build and Revision Numbers | |||
| // by using the '*' as shown below: | |||
| // [assembly: AssemblyVersion("1.0.*")] | |||
| [assembly: AssemblyVersion("1.0.0.0")] | |||
| [assembly: AssemblyFileVersion("1.0.0.0")] | |||
| @@ -0,0 +1,10 @@ | |||
| <?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.0" 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> | |||
| @@ -0,0 +1,23 @@ | |||
| using System; | |||
| using Tensorflow; | |||
| using Makina; | |||
| using Makina.Layers; | |||
| using NumSharp; | |||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |||
| namespace Makina.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.getShape()); | |||
| var outputShape = dense_1.output_shape(input.getShape()); | |||
| //Assert.AreEqual(outputShape.Dimensions, new int[] { 1 }); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,98 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Import Project="..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" /> | |||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| <ProjectGuid>{02F54D9F-617B-4B15-9D21-E21AF66693B1}</ProjectGuid> | |||
| <OutputType>Library</OutputType> | |||
| <AppDesignerFolder>Properties</AppDesignerFolder> | |||
| <RootNamespace>MakinaNET.Test</RootNamespace> | |||
| <AssemblyName>MakinaNET.Test</AssemblyName> | |||
| <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | |||
| <FileAlignment>512</FileAlignment> | |||
| <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | |||
| <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> | |||
| <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | |||
| <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> | |||
| <IsCodedUITest>False</IsCodedUITest> | |||
| <TestProjectType>UnitTest</TestProjectType> | |||
| <NuGetPackageImportStamp> | |||
| </NuGetPackageImportStamp> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| <DebugType>full</DebugType> | |||
| <Optimize>false</Optimize> | |||
| <OutputPath>bin\Debug\</OutputPath> | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| <DebugType>pdbonly</DebugType> | |||
| <Optimize>true</Optimize> | |||
| <OutputPath>bin\Release\</OutputPath> | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="ArrayFire, Version=0.0.2.0, Culture=neutral, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\ArrayFire.0.0.2\lib\netstandard2.0\ArrayFire.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="NumSharp.Core, Version=0.10.1.0, Culture=neutral, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\NumSharp.0.10.1\lib\netstandard2.0\NumSharp.Core.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System" /> | |||
| <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Core" /> | |||
| <Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Numerics" /> | |||
| <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | |||
| <HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath> | |||
| </Reference> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Compile Include="BaseTests.cs" /> | |||
| <Compile Include="Properties\AssemblyInfo.cs" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Include="app.config" /> | |||
| <None Include="packages.config" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="..\MakinaNET.Core\MakinaNET.Core.csproj"> | |||
| <Project>{6ff518eb-523f-4930-919e-05011efced6f}</Project> | |||
| <Name>MakinaNET.Core</Name> | |||
| </ProjectReference> | |||
| <ProjectReference Include="..\TensorFlowNET.Core\TensorFlowNET.Core.csproj"> | |||
| <Project>{fd682ac0-7b2d-45d3-8b0d-c6d678b04144}</Project> | |||
| <Name>TensorFlowNET.Core</Name> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | |||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
| <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | |||
| <PropertyGroup> | |||
| <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | |||
| </PropertyGroup> | |||
| <Error Condition="!Exists('..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" /> | |||
| <Error Condition="!Exists('..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" /> | |||
| </Target> | |||
| <Import Project="..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" /> | |||
| </Project> | |||
| @@ -0,0 +1,20 @@ | |||
| using System.Reflection; | |||
| using System.Runtime.CompilerServices; | |||
| using System.Runtime.InteropServices; | |||
| [assembly: AssemblyTitle("Makina.Test")] | |||
| [assembly: AssemblyDescription("")] | |||
| [assembly: AssemblyConfiguration("")] | |||
| [assembly: AssemblyCompany("")] | |||
| [assembly: AssemblyProduct("Makina.Test")] | |||
| [assembly: AssemblyCopyright("Copyright © 2019")] | |||
| [assembly: AssemblyTrademark("")] | |||
| [assembly: AssemblyCulture("")] | |||
| [assembly: ComVisible(false)] | |||
| [assembly: Guid("02f54d9f-617b-4b15-9d21-e21af66693b1")] | |||
| // [assembly: AssemblyVersion("1.0.*")] | |||
| [assembly: AssemblyVersion("1.0.0.0")] | |||
| [assembly: AssemblyFileVersion("1.0.0.0")] | |||
| @@ -0,0 +1,11 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <configuration> | |||
| <runtime> | |||
| <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |||
| <dependentAssembly> | |||
| <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> | |||
| <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> | |||
| </dependentAssembly> | |||
| </assemblyBinding> | |||
| </runtime> | |||
| </configuration> | |||
| @@ -0,0 +1,11 @@ | |||
| <?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> | |||