From 887cebbcbb87a8e4cd59f9d157621ca7e8eb41a8 Mon Sep 17 00:00:00 2001 From: deepakkumar1984 Date: Mon, 24 Apr 2023 08:40:42 +0930 Subject: [PATCH] Working on adding tf support. Using tf.kers 2.12 APIs for building --- Keras.NET.sln | 38 ++++++++++++++++++++++++++++++++++-- Keras/Keras.csproj | 1 + Keras/Layers/Core.cs | 2 +- Keras/Models/Model.cs | 5 +++-- Tensorflow/TensorSpec.cs | 9 +++++++++ Tensorflow/Tensorflow.csproj | 11 +++++++++++ 6 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 Tensorflow/TensorSpec.cs create mode 100644 Tensorflow/Tensorflow.csproj diff --git a/Keras.NET.sln b/Keras.NET.sln index d388a21..c55c9bd 100644 --- a/Keras.NET.sln +++ b/Keras.NET.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29123.88 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33502.453 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Keras.UnitTest", "Keras.UnitTest\Keras.UnitTest.csproj", "{0B402B43-29A2-4564-BC20-20BBBE7C2C51}" EndProject @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KerasExampleWinApp", "Examp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicGeneration", "Examples\MusicGeneration\MusicGeneration.csproj", "{108C3326-58D2-4C26-9D78-5F045D620A26}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tensorflow", "Tensorflow\Tensorflow.csproj", "{27230C96-FCB4-406C-8AAD-450020F9074D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -317,6 +319,38 @@ Global {108C3326-58D2-4C26-9D78-5F045D620A26}.Release|Any CPU.Build.0 = Release|Any CPU {108C3326-58D2-4C26-9D78-5F045D620A26}.Release|x64.ActiveCfg = Release|Any CPU {108C3326-58D2-4C26-9D78-5F045D620A26}.Release|x64.Build.0 = Release|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Debug|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Debug|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_Mono|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_Mono|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_Mono|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_Mono|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_OSX|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_OSX|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_OSX|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_OSX|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_WIN|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_WIN|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_WIN|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py2.7_WIN|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_Mono|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_Mono|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_Mono|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_Mono|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_OSX|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_OSX|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_OSX|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_OSX|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_WIN|Any CPU.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_WIN|Any CPU.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_WIN|x64.ActiveCfg = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Py3.6_WIN|x64.Build.0 = Debug|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Release|Any CPU.Build.0 = Release|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Release|x64.ActiveCfg = Release|Any CPU + {27230C96-FCB4-406C-8AAD-450020F9074D}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Keras/Keras.csproj b/Keras/Keras.csproj index 81081af..a5c2695 100644 --- a/Keras/Keras.csproj +++ b/Keras/Keras.csproj @@ -38,6 +38,7 @@ + diff --git a/Keras/Layers/Core.cs b/Keras/Layers/Core.cs index e72c1b0..3df484c 100644 --- a/Keras/Layers/Core.cs +++ b/Keras/Layers/Core.cs @@ -20,7 +20,7 @@ public class Input : BaseLayer /// The data type expected by the input, as a string (float32, float64, int32...) /// A boolean specifying whether the placeholder to be created is sparse. /// Optional existing tensor to wrap into the Input layer. If set, the layer will not create a placeholder tensor. - public Input(Shape shape, Shape batch_shape = null, string name = "", string dtype = "float32", bool sparse = false, NDarray tensor = null) + public Input(Shape shape, Shape batch_shape = null, string name = "", string dtype = "float32", bool sparse = false, NDarray tensor = null, bool? ragged = null) { this["shape"] = shape; this["batch_shape"] = batch_shape; diff --git a/Keras/Models/Model.cs b/Keras/Models/Model.cs index 42b400f..baf30eb 100644 --- a/Keras/Models/Model.cs +++ b/Keras/Models/Model.cs @@ -34,7 +34,8 @@ internal Model(PyObject obj) /// /// The inputs layers. /// The outputs layers. - public Model(BaseLayer[] inputs, BaseLayer[] outputs) + /// The layer name. + public Model(BaseLayer[] inputs, BaseLayer[] outputs, string name = null) { List inputList = new List(); List outputList = new List(); @@ -49,7 +50,7 @@ public Model(BaseLayer[] inputs, BaseLayer[] outputs) outputList.Add(item.PyInstance); } - PyInstance = Instance.keras.models.Model(inputList, outputList); + PyInstance = Instance.keras.models.Model(inputList, outputList, name); } /// diff --git a/Tensorflow/TensorSpec.cs b/Tensorflow/TensorSpec.cs new file mode 100644 index 0000000..4659afb --- /dev/null +++ b/Tensorflow/TensorSpec.cs @@ -0,0 +1,9 @@ +using System; + +namespace Tensorflow +{ + public class TensorSpec + { + + } +} diff --git a/Tensorflow/Tensorflow.csproj b/Tensorflow/Tensorflow.csproj new file mode 100644 index 0000000..6119911 --- /dev/null +++ b/Tensorflow/Tensorflow.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + +