diff --git a/TensorFlow.NET.sln b/TensorFlow.NET.sln
index a7d934d9..c5e28fd3 100644
--- a/TensorFlow.NET.sln
+++ b/TensorFlow.NET.sln
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.UnitTest", "test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Console", "src\TensorFlowNET.Console\TensorFlowNET.Console.csproj", "{03F06299-3F4B-4449-A709-3A647657BC0C}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.Keras", "src\TensorFlowNET.Keras\Tensorflow.Keras.csproj", "{49D71826-C03D-4FA7-9BAC-22C1327E65CF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -123,6 +125,30 @@ Global
{03F06299-3F4B-4449-A709-3A647657BC0C}.Release|x64.Build.0 = Release|Any CPU
{03F06299-3F4B-4449-A709-3A647657BC0C}.Release|x86.ActiveCfg = Release|Any CPU
{03F06299-3F4B-4449-A709-3A647657BC0C}.Release|x86.Build.0 = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug|x64.ActiveCfg = Debug|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug|x64.Build.0 = Debug|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug|x86.Build.0 = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug-Minimal|Any CPU.ActiveCfg = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug-Minimal|Any CPU.Build.0 = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug-Minimal|x64.ActiveCfg = Debug|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug-Minimal|x64.Build.0 = Debug|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug-Minimal|x86.ActiveCfg = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Debug-Minimal|x86.Build.0 = Debug|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Publish|Any CPU.ActiveCfg = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Publish|Any CPU.Build.0 = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Publish|x64.ActiveCfg = Debug|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Publish|x64.Build.0 = Debug|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Publish|x86.ActiveCfg = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Publish|x86.Build.0 = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Release|x64.ActiveCfg = Release|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Release|x64.Build.0 = Release|x64
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Release|x86.ActiveCfg = Release|Any CPU
+ {49D71826-C03D-4FA7-9BAC-22C1327E65CF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/TensorFlowNET.Console/Program.cs b/src/TensorFlowNET.Console/Program.cs
index e2360dff..7b91e6ad 100644
--- a/src/TensorFlowNET.Console/Program.cs
+++ b/src/TensorFlowNET.Console/Program.cs
@@ -1,5 +1,4 @@
using System;
-using static Tensorflow.Binding;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Console/TensorFlowNET.Console.csproj b/src/TensorFlowNET.Console/TensorFlowNET.Console.csproj
index da348aee..6cc631f4 100644
--- a/src/TensorFlowNET.Console/TensorFlowNET.Console.csproj
+++ b/src/TensorFlowNET.Console/TensorFlowNET.Console.csproj
@@ -12,7 +12,7 @@
-
+
diff --git a/src/TensorFlowNET.Core/APIs/tf.nn.cs b/src/TensorFlowNET.Core/APIs/tf.nn.cs
index f58536cb..f0c156fa 100644
--- a/src/TensorFlowNET.Core/APIs/tf.nn.cs
+++ b/src/TensorFlowNET.Core/APIs/tf.nn.cs
@@ -137,8 +137,6 @@ namespace Tensorflow
is_training: is_training,
name: name);
- public IPoolFunction max_pool_fn => new MaxPoolFunction();
-
public Tensor max_pool(Tensor value, int[] ksize, int[] strides, string padding, string data_format = "NHWC", string name = null)
=> nn_ops.max_pool(value, ksize, strides, padding, data_format: data_format, name: name);
diff --git a/src/TensorFlowNET.Core/APIs/tf.optimizers.cs b/src/TensorFlowNET.Core/APIs/tf.optimizers.cs
deleted file mode 100644
index 8385b57d..00000000
--- a/src/TensorFlowNET.Core/APIs/tf.optimizers.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************
- Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using Tensorflow.Keras.Optimizers;
-
-namespace Tensorflow
-{
- public partial class tensorflow
- {
- public KerasOptimizers optimizers => new KerasOptimizers();
-
- public class KerasOptimizers
- {
- public SGD SGD(float learning_rate) => new SGD(learning_rate);
-
- public Adam Adam(float learning_rate = 0.001f,
- float beta_1 = 0.9f,
- float beta_2 = 0.999f,
- float epsilon = 1e-7f,
- bool amsgrad = false,
- string name = "Adam") => new Adam(learning_rate: learning_rate,
- beta_1: beta_1,
- beta_2: beta_2,
- epsilon: epsilon,
- amsgrad: amsgrad,
- name: name);
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/APIs/tf.train.cs b/src/TensorFlowNET.Core/APIs/tf.train.cs
index 9db0b8eb..cf02ed59 100644
--- a/src/TensorFlowNET.Core/APIs/tf.train.cs
+++ b/src/TensorFlowNET.Core/APIs/tf.train.cs
@@ -15,7 +15,6 @@
******************************************************************************/
using System.Collections.Generic;
-using Tensorflow.Keras.Optimizers;
using Tensorflow.Train;
namespace Tensorflow
@@ -87,7 +86,7 @@ namespace Tensorflow
public CheckpointState get_checkpoint_state(string checkpoint_dir, string latest_filename = null)
=> checkpoint_management.get_checkpoint_state(checkpoint_dir, latest_filename: latest_filename);
- public Tensor polynomial_decay(float learning_rate,
+ /*public Tensor polynomial_decay(float learning_rate,
RefVariable global_step,
float decay_steps,
float end_learning_rate = 0.0001f,
@@ -105,7 +104,7 @@ namespace Tensorflow
var decayed_lr = decayed.__call__(global_step);
return decayed_lr;
- }
+ }*/
}
}
}
diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs
index 23fa1d45..63de54ad 100644
--- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs
+++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs
@@ -14,7 +14,7 @@ namespace Tensorflow.Keras.ArgsDefinition
public int MaxQueueSize { get; set; } = 10;
public int Workers { get; set; } = 1;
public bool UseMultiprocessing { get; set; } = false;
- public Model Model { get; set; }
+ public IModel Model { get; set; }
public IVariableV1 StepsPerExecution { get; set; }
}
}
diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs
index 6c3284d3..ad321810 100644
--- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs
+++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs
@@ -4,7 +4,7 @@ namespace Tensorflow.Keras.ArgsDefinition
{
public class NodeArgs
{
- public Layer[] InboundLayers { get; set; }
+ public ILayer[] InboundLayers { get; set; }
public int[] NodeIndices { get; set; }
public int[] TensorIndices { get; set; }
public Tensors InputTensors { get; set; }
diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs
index fbdb378d..3aa22a75 100644
--- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs
+++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs
@@ -5,6 +5,6 @@ namespace Tensorflow.Keras.ArgsDefinition
{
public class SequentialArgs : ModelArgs
{
- public List Layers { get; set; }
+ public List Layers { get; set; }
}
}
diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs
index ed8d8bf1..921a4726 100644
--- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs
+++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs
@@ -13,6 +13,6 @@ namespace Tensorflow.Keras.ArgsDefinition
public int MaxQueueSize { get; set; }
public int Worker { get; set; }
public bool UseMultiprocessing { get; set; }
- public Model Model { get; set; }
+ public IModel Model { get; set; }
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs b/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs
deleted file mode 100644
index 4cc4dbdb..00000000
--- a/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************************
- Copyright 2020 Haiping Chen. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using NumSharp;
-using System;
-using System.IO;
-using System.Net;
-
-namespace Tensorflow.Keras.Datasets
-{
- public class Mnist
- {
- string origin_folder = "https://storage.googleapis.com/tensorflow/tf-keras-datasets/";
- string file_name = "mnist.npz";
-
- ///
- /// Loads the [MNIST dataset](http://yann.lecun.com/exdb/mnist/).
- ///
- ///
- public DatasetPass load_data()
- {
- var file = Download();
- var bytes = File.ReadAllBytes(file);
- var datax = LoadX(bytes);
- var datay = LoadY(bytes);
- return new DatasetPass
- {
- Train = (datax.Item1, datay.Item1),
- Test = (datax.Item2, datay.Item2)
- };
- }
-
- (NDArray, NDArray) LoadX(byte[] bytes)
- {
- var y = np.Load_Npz(bytes);
- return (y["x_train.npy"], y["x_test.npy"]);
- }
-
- (NDArray, NDArray) LoadY(byte[] bytes)
- {
- var y = np.Load_Npz(bytes);
- return (y["y_train.npy"], y["y_test.npy"]);
- }
-
- string Download()
- {
- var fileSaveTo = Path.Combine(Path.GetTempPath(), file_name);
-
- if (File.Exists(fileSaveTo))
- {
- Console.WriteLine($"The file {fileSaveTo} already exists");
- return fileSaveTo;
- }
-
- using var wc = new WebClient();
- wc.DownloadFileTaskAsync(origin_folder + file_name, fileSaveTo).Wait();
-
- return fileSaveTo;
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs b/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs
deleted file mode 100644
index 3768ed52..00000000
--- a/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Tensorflow.Keras.Engine
-{
- public class CallContext
- {
- public CallContextManager enter()
- {
- return new CallContextManager();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/InputSpec.cs b/src/TensorFlowNET.Core/Keras/Engine/IModel.cs
similarity index 81%
rename from src/TensorFlowNET.Keras/Engine/InputSpec.cs
rename to src/TensorFlowNET.Core/Keras/Engine/IModel.cs
index 7246cce0..4af29de3 100644
--- a/src/TensorFlowNET.Keras/Engine/InputSpec.cs
+++ b/src/TensorFlowNET.Core/Keras/Engine/IModel.cs
@@ -4,7 +4,7 @@ using System.Text;
namespace Tensorflow.Keras.Engine
{
- class InputSpec
+ public interface IModel
{
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/INode.cs b/src/TensorFlowNET.Core/Keras/Engine/INode.cs
new file mode 100644
index 00000000..b6de99b2
--- /dev/null
+++ b/src/TensorFlowNET.Core/Keras/Engine/INode.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tensorflow.Keras.Engine
+{
+ public interface INode
+ {
+ Tensors input_tensors { get; }
+ Tensors Outputs { get; }
+ ILayer Layer { get; set; }
+ List KerasInputs { get; set; }
+ INode[] ParentNodes { get; }
+ IEnumerable<(ILayer, int, int, Tensor)> iterate_inbound();
+ }
+}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs b/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs
index 0450c726..d218c17e 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs
+++ b/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs
@@ -5,12 +5,13 @@
///
public class KerasHistory
{
- Layer layer;
+ ILayer layer;
+ public ILayer Layer => layer;
int node_index;
int tensor_index;
Tensor tensor;
- public KerasHistory(Layer layer, int node_index, int tensor_index, Tensor tensor)
+ public KerasHistory(ILayer layer, int node_index, int tensor_index, Tensor tensor)
{
this.layer = layer;
this.node_index = node_index;
@@ -18,7 +19,7 @@
this.tensor = tensor;
}
- public void Deconstruct(out Layer layer, out int node_index, out int tensor_index)
+ public void Deconstruct(out ILayer layer, out int node_index, out int tensor_index)
{
layer = this.layer;
node_index = this.node_index;
@@ -27,8 +28,5 @@
public override string ToString()
=> $"{layer.GetType().Name} {layer.Name} {tensor.name}";
-
- public static implicit operator Layer(KerasHistory history)
- => history.layer;
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Node.cs b/src/TensorFlowNET.Core/Keras/Engine/Node.cs
deleted file mode 100644
index 3c4d88ad..00000000
--- a/src/TensorFlowNET.Core/Keras/Engine/Node.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-/*****************************************************************************
- Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using System.Collections.Generic;
-using System.Linq;
-using Tensorflow.Keras.ArgsDefinition;
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Keras.Engine
-{
- ///
- /// A `Node` describes the connectivity between two layers.
- ///
- /// Each time a layer is connected to some new input,
- /// a node is added to `layer._inbound_nodes`.
- /// Each time the output of a layer is used by another layer,
- /// a node is added to `layer._outbound_nodes`.
- ///
- public partial class Node
- {
- NodeArgs args;
-
- public int[] node_indices;
- public int[] tensor_indices;
- public Tensors input_tensors => args.InputTensors;
- public Tensors Outputs => args.Outputs;
- public TensorShape[] input_shapes;
- public TensorShape[] output_shapes;
- public List KerasInputs = new List();
- public Layer Layer { get; set; }
- public bool IsInput => args.InputTensors == null;
- public int[] FlatInputIds { get; set; }
- public int[] FlatOutputIds { get; set; }
- bool _single_positional_tensor_passed => KerasInputs.Count() == 1;
- Dictionary _keras_inputs_ids_and_indices = new Dictionary();
- public Node[] ParentNodes
- {
- get
- {
- var node_deps = new List();
- foreach (var kt in KerasInputs)
- {
- var (layer, node_index, _) = kt.KerasHistory;
- if (layer != null)
- node_deps.append(layer.InboundNodes[node_index]);
- }
- return node_deps.ToArray();
- }
- }
-
- public Node(Layer layer, NodeArgs args)
- {
- this.args = args;
- this.Layer = layer;
-
- if (args.InputTensors != null)
- KerasInputs.AddRange(args.InputTensors);
-
- foreach (var (i, ele) in enumerate(KerasInputs))
- _keras_inputs_ids_and_indices[i] = ele.GetHashCode();
-
- // Wire up Node to Layers.
- layer.InboundNodes.Add(this);
- foreach (var kt in KerasInputs)
- {
- if (kt.KerasHistory == null)
- continue;
- var (inbound_layer, _, _) = kt.KerasHistory;
- if (inbound_layer != null)
- inbound_layer.OutboundNodes.Add(this);
- }
-
- // Set metadata on outputs.
- var node_index = layer.InboundNodes.Count - 1;
- foreach (var (i, tensor) in enumerate(Outputs))
- tensor.KerasHistory = new KerasHistory(layer, node_index, i, tensor);
-
- // Cached for performance.
- FlatInputIds = KerasInputs.Select(x => x.GetHashCode()).ToArray();
- FlatOutputIds = Outputs.Select(x => x.GetHashCode()).ToArray();
- }
-
- ///
- /// Maps Keras Tensors to computed Tensors using `tensor_dict`.
- ///
- ///
- ///
- public Tensors MapArguments(Dictionary> tensor_dict)
- {
- if (_single_positional_tensor_passed)
- {
- var kt_id = _keras_inputs_ids_and_indices[0];
- return tensor_dict[kt_id].Dequeue();
- }
- else
- {
- var flat_arguments = KerasInputs.Select(x => x).ToArray();
- foreach (var (kt_index, kt_id) in enumerate(_keras_inputs_ids_and_indices))
- flat_arguments[kt_index] = tensor_dict[kt_id].Dequeue();
-
- return flat_arguments;
- }
- }
-
- public override string ToString()
- => $"{Layer.Name}, {KerasInputs.Count} inputs: {string.Join(",", KerasInputs.Select(x => x.name))}";
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs b/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs
deleted file mode 100644
index f4b66896..00000000
--- a/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-/*****************************************************************************
- Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using System.Collections.Generic;
-using Tensorflow.Keras.ArgsDefinition;
-using Tensorflow.Keras.Layers;
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Keras.Engine
-{
- ///
- /// `Sequential` groups a linear stack of layers into a `tf.keras.Model`.
- /// `Sequential` provides training and inference features on this model.
- ///
- public class Sequential : Model
- {
- SequentialArgs args;
- bool _is_graph_network;
- Tensor inputs;
- Tensor outputs;
-
- bool computeOutputAndMaskJointly;
- bool autoTrackSubLayers;
- TensorShape inferredInputShape;
- bool hasExplicitInputShape;
- TF_DataType inputDType;
- List layers => args.Layers;
- public TensorShape output_shape => outputs.TensorShape;
- bool built = false;
-
- public Sequential(SequentialArgs args)
- : base(new ModelArgs
- {
- Name = args.Name
- })
- {
- this.args = args;
- if (args.Layers == null)
- args.Layers = new List();
- // SupportsMasking = true;
- computeOutputAndMaskJointly = true;
- autoTrackSubLayers = false;
- hasExplicitInputShape = false;
- _is_graph_network = false;
- }
-
- public void add(Tensor tensor)
- {
- Layer layer = tensor.KerasHistory;
- add(layer);
- }
-
- ///
- /// Adds a layer instance on top of the layer stack.
- ///
- ///
- public void add(Layer layer)
- {
- built = false;
- var set_inputs = false;
- if (layers.Count == 0)
- {
- if (layer is InputLayer)
- {
- set_inputs = true;
- }
- else
- {
- if (layer.BatchInputShape != null)
- {
- // Instantiate an input layer.
- var x = tf.keras.Input(
- shape: layer.BatchInputShape,
- dtype: layer.DType,
- name: layer.Name + "_input");
-
- // This will build the current layer
- // and create the node connecting the current layer
- // to the input layer we just created.
- layer.Apply(x);
- set_inputs = true;
- }
- }
-
- if (set_inputs)
- {
- // If an input layer (placeholder) is available.
- outputs = layer.InboundNodes[^1].Outputs;
- }
-
- }
- else if (outputs != null)
- {
- outputs = layer.Apply(outputs);
- }
-
- if (set_inputs || _is_graph_network)
- {
- _init_graph_network(inputs, outputs);
- }
- else
- {
-
- }
- }
-
- void _init_graph_network(Tensor inputs, Tensor outputs)
- {
- _is_graph_network = true;
- this.inputs = inputs;
- this.outputs = outputs;
- built = true;
- _map_graph_network(inputs, outputs);
- }
-
- void _map_graph_network(Tensor inputs, Tensor outputs)
- {
- layers.add(outputs.KerasHistory);
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/ILayer.cs b/src/TensorFlowNET.Core/Keras/Layers/ILayer.cs
new file mode 100644
index 00000000..ef39f7e7
--- /dev/null
+++ b/src/TensorFlowNET.Core/Keras/Layers/ILayer.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tensorflow.Keras.Engine;
+
+namespace Tensorflow.Keras
+{
+ public interface ILayer
+ {
+ string Name { get; }
+ bool Trainable { get; }
+ List Layers { get; }
+ List InboundNodes { get; }
+ List OutboundNodes { get; }
+ Tensors Apply(Tensors inputs, Tensor state = null, bool is_training = false);
+ List trainable_variables { get; }
+ TensorShape output_shape { get; }
+ int count_params();
+ }
+}
diff --git a/src/TensorFlowNET.Core/Keras/Losses/Loss.cs b/src/TensorFlowNET.Core/Keras/Losses/Loss.cs
deleted file mode 100644
index 07d629b6..00000000
--- a/src/TensorFlowNET.Core/Keras/Losses/Loss.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using Tensorflow.Keras.Utils;
-
-namespace Tensorflow.Keras.Losses
-{
- ///
- /// Loss base class.
- ///
- public abstract class Loss
- {
- protected string reduction;
- protected string name;
- bool _allow_sum_over_batch_size;
- string _name_scope;
-
- public string Reduction => reduction;
-
- public Loss(string reduction = ReductionV2.AUTO, string name = null)
- {
- this.reduction = reduction;
- this.name = name;
- _allow_sum_over_batch_size = false;
- }
-
- public virtual Tensor Apply(Tensor y_true, Tensor y_pred, bool from_logits = false, int axis = -1)
- {
- throw new NotImplementedException("");
- }
-
- public Tensor Call(Tensor y_true, Tensor y_pred)
- {
- var losses = Apply(y_true, y_pred);
- return losses_utils.compute_weighted_loss(losses, reduction: ReductionV2.SUM_OVER_BATCH_SIZE);
- }
-
- void _set_name_scope()
- {
- _name_scope = name;
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs b/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs
deleted file mode 100644
index af352aa9..00000000
--- a/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Tensorflow.Keras.Losses
-{
- public class LossFunctionWrapper : Loss
- {
- public LossFunctionWrapper(string reduction = ReductionV2.AUTO,
- string name = null)
- : base(reduction: reduction,
- name: name)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs b/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs
deleted file mode 100644
index fe14e887..00000000
--- a/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Keras.Losses
-{
- public class SparseCategoricalCrossentropy : LossFunctionWrapper, ILossFunc
- {
- public SparseCategoricalCrossentropy(bool from_logits = false,
- string reduction = ReductionV2.AUTO,
- string name = "sparse_categorical_crossentropy") :
- base(reduction: reduction,
- name: name)
- {
-
- }
-
- public override Tensor Apply(Tensor target, Tensor output, bool from_logits = false, int axis = -1)
- {
- target = tf.cast(target, dtype: TF_DataType.TF_INT64);
-
- // Try to adjust the shape so that rank of labels = rank of logits - 1.
- var output_shape = array_ops.shape_v2(output);
- var output_rank = output.TensorShape.ndim;
- var target_rank = target.TensorShape.ndim;
- var update_shape = target_rank != output_rank - 1;
- if (update_shape)
- {
- target = array_ops.reshape(target, new int[] { -1 });
- output = array_ops.reshape(output, new int[] { -1, output_shape[-1].numpy() });
- }
- return tf.nn.sparse_softmax_cross_entropy_with_logits(target, output);
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs b/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs
deleted file mode 100644
index 8a55690b..00000000
--- a/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Tensorflow.Keras.Metrics
-{
- ///
- /// Computes the (weighted) mean of the given values.
- ///
- public class Mean : Reduce
- {
- public Mean(string name = "mean", TF_DataType dtype = TF_DataType.TF_FLOAT)
- : base(Reduction.WEIGHTED_MEAN, name, dtype: dtype)
- {
-
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Metrics/MeanMetricWrapper.cs b/src/TensorFlowNET.Core/Keras/Metrics/MeanMetricWrapper.cs
deleted file mode 100644
index 3bdfe6d3..00000000
--- a/src/TensorFlowNET.Core/Keras/Metrics/MeanMetricWrapper.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanMetricWrapper : Mean
- {
- string name;
- Func _fn = null;
-
- public MeanMetricWrapper(Func fn, string name, TF_DataType dtype = TF_DataType.TF_FLOAT)
- : base(name: name, dtype: dtype)
- {
- _fn = fn;
- }
-
- public override Tensor update_state(Tensor y_true, Tensor y_pred, Tensor sample_weight = null)
- {
- y_true = math_ops.cast(y_true, _dtype);
- y_pred = math_ops.cast(y_pred, _dtype);
-
- var matches = _fn(y_true, y_pred);
- return update_state(matches, sample_weight: sample_weight);
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs b/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs
deleted file mode 100644
index 9cbaaeb7..00000000
--- a/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using Tensorflow.Keras.ArgsDefinition;
-using Tensorflow.Keras.Engine;
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Keras.Metrics
-{
- ///
- /// Encapsulates metric logic and state.
- ///
- public class Metric : Layer
- {
- protected IVariableV1 total;
- protected IVariableV1 count;
- protected string _reduction;
- protected TF_DataType _dtype;
-
- public Metric(string name = null, TF_DataType dtype = TF_DataType.DtInvalid)
- : base(new LayerArgs
- {
- Name = name,
- DType = dtype
- })
- {
- stateful = true;
- built = true;
- }
-
- protected override IVariableV1 add_weight(string name,
- TensorShape shape = null,
- TF_DataType dtype = TF_DataType.TF_FLOAT,
- IInitializer initializer = null,
- IRegularizer regularizer = null,
- VariableSynchronization synchronization = VariableSynchronization.OnRead,
- VariableAggregation aggregation = VariableAggregation.Sum,
- bool trainable = true,
- Func getter = null)
- {
- if (shape == null)
- shape = new TensorShape(new int[0]);
-
- return tf_with(ops.init_scope(), delegate
- {
- return base.add_weight(name, shape,
- dtype: dtype,
- trainable: false,
- initializer: initializer,
- synchronization: synchronization,
- aggregation: aggregation);
- });
- }
-
- public virtual Tensor update_state(Tensor y_true, Tensor y_pred, Tensor sample_weight = null)
- => throw new NotImplementedException("");
-
- public virtual Tensor result()
- => throw new NotImplementedException("");
-
- public override string ToString()
- => $"{name} {(float)total.numpy()}/{(float)count.numpy()}";
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs b/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs
deleted file mode 100644
index f7cdb8f5..00000000
--- a/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using Tensorflow.Keras.Losses;
-using Tensorflow.Keras.Utils;
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Keras.Metrics
-{
- ///
- /// Encapsulates metrics that perform a reduce operation on the values.
- ///
- public class Reduce : Metric
- {
- public Reduce(string reduction, string name, TF_DataType dtype = TF_DataType.DtInvalid)
- : base(name: name, dtype: dtype)
- {
- _reduction = reduction;
- _dtype = dtype;
- total = add_weight("total", initializer: tf.zeros_initializer);
-
- if (reduction == Reduction.WEIGHTED_MEAN ||
- reduction == Reduction.SUM_OVER_BATCH_SIZE)
- {
- count = add_weight("count", initializer: tf.zeros_initializer);
- }
- }
-
- public Tensor update_state(Tensor values, Tensor sample_weight = null)
- {
- if (sample_weight != null)
- {
- (values, sample_weight) = losses_utils.squeeze_or_expand_dimensions(
- values, sample_weight: sample_weight);
-
- sample_weight = math_ops.cast(sample_weight, dtype: values.dtype);
- values = math_ops.multiply(values, sample_weight);
- }
-
- Tensor update_total_op = null;
- var value_sum = math_ops.reduce_sum(values);
- tf_with(ops.control_dependencies(new[] { value_sum }), ctl =>
- {
- update_total_op = total.assign_add(value_sum);
- });
-
- // Exit early if the reduction doesn't have a denominator.
- if (_reduction == Reduction.SUM)
- return update_total_op;
-
- // Update `count` for reductions that require a denominator.
- Tensor num_values = null;
- if (_reduction == Reduction.SUM_OVER_BATCH_SIZE)
- num_values = math_ops.cast(array_ops.size(values), _dtype);
- else if (_reduction == ReductionV2.WEIGHTED_MEAN)
- {
- if (sample_weight == null)
- num_values = math_ops.cast(array_ops.size(values), _dtype);
- else
- num_values = math_ops.reduce_sum(sample_weight);
- }
-
- return tf_with(ops.control_dependencies(new[] { update_total_op }), ctl
- => count.assign_add(num_values));
- }
-
- public override Tensor result()
- {
- if (_reduction == Reduction.SUM)
- return array_ops.identity(total.AsTensor());
- else if (_reduction == Reduction.WEIGHTED_MEAN || _reduction == Reduction.SUM_OVER_BATCH_SIZE)
- return math_ops.div_no_nan(total.AsTensor(), count.AsTensor());
-
- return base.result();
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs b/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs
deleted file mode 100644
index bf69980c..00000000
--- a/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Tensorflow.Keras.Metrics
-{
- class Sum
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Layers/Layer.cs b/src/TensorFlowNET.Core/Layers/Layer.cs
deleted file mode 100644
index 9be4ff94..00000000
--- a/src/TensorFlowNET.Core/Layers/Layer.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-/*****************************************************************************
- Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using Tensorflow.Keras.ArgsDefinition;
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Layers
-{
- public class Layer : Keras.Engine.Layer
- {
- protected Graph _graph;
-
- protected VariableScope _scope;
- protected VariableScope _current_scope;
-
- protected bool? _reuse;
- protected bool _use_resource_variables;
- protected bool _keras_style;
-
- public Layer(bool trainable = true,
- string name = null,
- TF_DataType dtype = TF_DataType.DtInvalid,
- bool? _reuse = null) :
- base(new LayerArgs
- {
- Trainable = trainable,
- Name = name,
- DType = dtype
- })
- {
- // For backwards compatibility, legacy layers do not use `ResourceVariable`
- // by default.
- this._use_resource_variables = false;
- this._reuse = _reuse;
-
- // Avoid an incorrect lint error
- trainable_weights = new List();
- non_trainable_weights = new List();
- this.built = false;
- _keras_style = false;
- }
-
- public virtual (Tensor, Tensor) apply(Tensor inputs, Tensor training = null)
- {
- var results = __call__(inputs, training: training);
- return (results[0], results[1]);
- }
-
- public Tensors __call__(Tensors inputs,
- Tensor state = null,
- Tensor training = null,
- VariableScope scope = null)
- {
- _set_scope(scope);
- _graph = ops._get_graph_from_inputs(inputs, graph: _graph);
-
- variable_scope scope_context_manager = null;
- if (built)
- {
- scope_context_manager = tf.variable_scope(_scope,
- reuse: true,
- auxiliary_name_scope: false);
- }
- else
- {
- scope_context_manager = tf.variable_scope(_scope,
- reuse: _reuse,
- auxiliary_name_scope: false);
- }
-
- Tensors outputs = null;
- tf_with(scope_context_manager, scope2 =>
- {
- _current_scope = scope2;
- // Actually call layer
- outputs = base.Apply(inputs,
- state: state,
- is_training: training == null ? false : false);
- });
-
-
- // Update global default collections.
- _add_elements_to_collection(updates.ToArray(), new string[] { tf.GraphKeys.UPDATE_OPS });
-
- return outputs;
- }
-
- protected virtual void _add_elements_to_collection(Operation[] elements, string[] collection_list)
- {
- foreach (var name in collection_list)
- {
- var collection = ops.get_collection_ref(name);
-
- foreach (var element in elements)
- if (!collection.Contains(element))
- collection.Add(element);
- }
- }
-
- ///
- /// Adds a new variable to the layer, or gets an existing one; returns it.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- protected virtual IVariableV1 add_weight(string name,
- int[] shape,
- TF_DataType dtype = TF_DataType.DtInvalid,
- IInitializer initializer = null,
- bool trainable = true,
- VariableSynchronization synchronization = VariableSynchronization.Auto,
- VariableAggregation aggregation = VariableAggregation.None)
- {
- var default_graph = ops.get_default_graph();
- Graph init_graph = null;
- IVariableV1[] existing_variables = null;
-
- if (synchronization == VariableSynchronization.OnRead)
- trainable = false;
-
- if (default_graph.building_function)
- {
- throw new NotImplementedException("add_weight");
- }
- else
- {
- init_graph = default_graph;
- existing_variables = variables.global_variables().ToArray();
- }
-
- if (dtype == TF_DataType.DtInvalid)
- dtype = TF_DataType.TF_FLOAT;
-
- _set_scope();
- var reuse = built || (_reuse != null && _reuse.Value);
- return tf_with(tf.variable_scope(_scope,
- reuse: reuse,
- auxiliary_name_scope: false), scope =>
- {
- _current_scope = scope;
- return tf_with(ops.name_scope(_name_scope()), delegate
- {
- var variable = base.add_weight(name,
- shape,
- dtype: dtype,
- initializer: initializer,
- trainable: trainable,
- getter: (args) =>
- tf.compat.v1.get_variable(args.Name,
- shape: args.Shape,
- dtype: args.DType,
- initializer: args.Initializer,
- trainable: args.Trainable)
- );
-
- //if (init_graph != null)
- //var trainable_variables = variables.trainable_variables();
-
- return variable;
- });
- });
- }
-
- protected override string _name_scope()
- {
- return _current_scope.original_name_scope;
- }
-
- protected void _set_scope(VariableScope scope = null)
- {
- if (_scope == null)
- {
- if (_reuse.HasValue && _reuse.Value)
- {
- throw new NotImplementedException("_set_scope _reuse.HasValue");
- /*with(tf.variable_scope(scope == null ? _base_name : scope),
- captured_scope => _scope = captured_scope);*/
- }
- else
- {
- tf_with(tf.variable_scope(scope, default_name: base_name), captured_scope =>
- {
- // convert variable_scope to VariableScope
- _scope = captured_scope;
- });
- }
- }
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs
index a9c43eb0..11d248a4 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs
@@ -71,7 +71,7 @@ namespace Tensorflow
///
///
///
- protected override Tensors Call(Tensors inputs, Tensor state = null, bool is_training = false)
+ protected Tensors Call(Tensors inputs, Tensor state = null, bool is_training = false)
{
var one = constant_op.constant(1, dtype: dtypes.int32);
// Parameters of gates are concatenated into one multiply for efficiency.
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs
index 34867de4..4a03ca85 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs
@@ -66,7 +66,7 @@ namespace Tensorflow
built = true;
}
- protected override Tensors Call(Tensors inputs, Tensor state = null, bool is_training = false)
+ protected Tensors Call(Tensors inputs, Tensor state = null, bool is_training = false)
{
// Most basic RNN: output = new_state = act(W * input + U * state + B).
var concat = array_ops.concat(new Tensor[] { inputs, state }, 1);
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs b/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs
index 487b2612..e374ff66 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs
@@ -22,7 +22,7 @@ using static Tensorflow.Binding;
namespace Tensorflow.Operations
{
- internal class ConvolutionInternal
+ public class ConvolutionInternal
{
ConvolutionalArgs args;
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/LayerRNNCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/LayerRNNCell.cs
index 16aa147c..442fc8f6 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/LayerRNNCell.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/LayerRNNCell.cs
@@ -13,17 +13,165 @@
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
+using static Tensorflow.Binding;
+using Tensorflow.Keras.Engine;
+using System;
namespace Tensorflow
{
public class LayerRnnCell : RnnCell
{
- public LayerRnnCell(bool? _reuse = null,
- string name = null,
- TF_DataType dtype = TF_DataType.DtInvalid) : base(_reuse: _reuse,
+ protected InputSpec inputSpec;
+ protected bool built;
+ protected Graph _graph;
+
+ protected VariableScope _scope;
+ protected VariableScope _current_scope;
+
+ protected bool? _reuse;
+ protected bool _use_resource_variables;
+ protected bool _keras_style;
+
+ public LayerRnnCell(bool trainable = true,
+ string name = null,
+ TF_DataType dtype = TF_DataType.DtInvalid,
+ bool? _reuse = null) : base(_reuse: _reuse,
name: name,
dtype: dtype)
{
+ // For backwards compatibility, legacy layers do not use `ResourceVariable`
+ // by default.
+ this._use_resource_variables = false;
+ this._reuse = _reuse;
+
+ // Avoid an incorrect lint error
+ this.built = false;
+ _keras_style = false;
+ }
+
+ protected virtual void build(TensorShape inputs_shape)
+ {
+
+ }
+
+ public virtual (Tensor, Tensor) apply(Tensor inputs, Tensor training = null)
+ {
+ var results = __call__(inputs, training: training);
+ return (results[0], results[1]);
+ }
+
+ public Tensors __call__(Tensors inputs,
+ Tensor state = null,
+ Tensor training = null,
+ VariableScope scope = null)
+ {
+ _set_scope(scope);
+ _graph = ops._get_graph_from_inputs(inputs, graph: _graph);
+
+ variable_scope scope_context_manager = null;
+ if (built)
+ {
+ scope_context_manager = tf.variable_scope(_scope,
+ reuse: true,
+ auxiliary_name_scope: false);
+ }
+ else
+ {
+ scope_context_manager = tf.variable_scope(_scope,
+ reuse: _reuse,
+ auxiliary_name_scope: false);
+ }
+
+ Tensors outputs = null;
+ tf_with(scope_context_manager, scope2 =>
+ {
+ _current_scope = scope2;
+ // Actually call layer
+
+ });
+
+
+ // Update global default collections.
+
+ return outputs;
+ }
+
+ protected virtual void _add_elements_to_collection(Operation[] elements, string[] collection_list)
+ {
+ foreach (var name in collection_list)
+ {
+ var collection = ops.get_collection_ref(name);
+
+ foreach (var element in elements)
+ if (!collection.Contains(element))
+ collection.Add(element);
+ }
+ }
+
+ ///
+ /// Adds a new variable to the layer, or gets an existing one; returns it.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected virtual IVariableV1 add_weight(string name,
+ int[] shape,
+ TF_DataType dtype = TF_DataType.DtInvalid,
+ IInitializer initializer = null,
+ bool trainable = true,
+ VariableSynchronization synchronization = VariableSynchronization.Auto,
+ VariableAggregation aggregation = VariableAggregation.None)
+ {
+ var default_graph = ops.get_default_graph();
+ Graph init_graph = null;
+ IVariableV1[] existing_variables = null;
+
+ if (synchronization == VariableSynchronization.OnRead)
+ trainable = false;
+
+ if (default_graph.building_function)
+ {
+ throw new NotImplementedException("add_weight");
+ }
+ else
+ {
+ init_graph = default_graph;
+ existing_variables = variables.global_variables().ToArray();
+ }
+
+ if (dtype == TF_DataType.DtInvalid)
+ dtype = TF_DataType.TF_FLOAT;
+
+ _set_scope();
+ var reuse = built || (_reuse != null && _reuse.Value);
+ return tf.Variable(0);
+ }
+
+ protected string _name_scope()
+ {
+ return _current_scope.original_name_scope;
+ }
+
+ protected void _set_scope(VariableScope scope = null)
+ {
+ if (_scope == null)
+ {
+ if (_reuse.HasValue && _reuse.Value)
+ {
+ throw new NotImplementedException("_set_scope _reuse.HasValue");
+ /*with(tf.variable_scope(scope == null ? _base_name : scope),
+ captured_scope => _scope = captured_scope);*/
+ }
+ else
+ {
+
+ }
+ }
}
}
}
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs
index b04dc152..3c717825 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs
@@ -15,6 +15,9 @@
******************************************************************************/
using System;
+using System.Collections.Generic;
+using Tensorflow.Keras;
+using Tensorflow.Keras.Engine;
using Tensorflow.Operations;
using Tensorflow.Util;
using static Tensorflow.Binding;
@@ -42,7 +45,7 @@ namespace Tensorflow
/// matching structure of Tensors having shape `[batch_size].concatenate(s)`
/// for each `s` in `self.batch_size`.
///
- public abstract class RnnCell : Layers.Layer
+ public abstract class RnnCell : ILayer
{
///
/// Attribute that indicates whether the cell is a TF RNN cell, due the slight
@@ -52,14 +55,24 @@ namespace Tensorflow
public virtual object state_size { get; }
public virtual int output_size { get; }
+ public string Name { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
+
+ public List InboundNodes => throw new NotImplementedException();
+
+ public List OutboundNodes => throw new NotImplementedException();
+
+ public List Layers => throw new NotImplementedException();
+
+ public bool Trainable => throw new NotImplementedException();
+
+ public List trainable_variables => throw new NotImplementedException();
+
+ public TensorShape output_shape => throw new NotImplementedException();
public RnnCell(bool trainable = true,
string name = null,
TF_DataType dtype = TF_DataType.DtInvalid,
- bool? _reuse = null) : base(trainable: trainable,
- name: name,
- dtype: dtype,
- _reuse: _reuse)
+ bool? _reuse = null)
{
_is_tf_rnn_cell = true;
}
@@ -109,5 +122,15 @@ namespace Tensorflow
throw new NotImplementedException("_zero_state_tensors");
}
+
+ public Tensors Apply(Tensors inputs, Tensor state = null, bool is_training = false)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int count_params()
+ {
+ throw new NotImplementedException();
+ }
}
}
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
index bd9513e2..58b299eb 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
@@ -363,8 +363,8 @@ namespace Tensorflow.Operations
Tensor[] outputs = null;
if (sequence_length != null)
throw new NotImplementedException("sequence_length != null");
- else
- outputs = cell.__call__(input_t_t, state: state1);
+ /*else
+ outputs = cell.__call__(input_t_t, state: state1);*/
var (output, new_state) = (outputs[0], outputs[1]);
// Keras cells always wrap state as list, even if it's a single tensor.
diff --git a/src/TensorFlowNET.Core/Operations/nn_ops.cs b/src/TensorFlowNET.Core/Operations/nn_ops.cs
index b70eeab5..038c1a5d 100644
--- a/src/TensorFlowNET.Core/Operations/nn_ops.cs
+++ b/src/TensorFlowNET.Core/Operations/nn_ops.cs
@@ -24,7 +24,7 @@ namespace Tensorflow
{
public class nn_ops
{
- internal static ConvolutionInternal convolution_internal(string padding,
+ public static ConvolutionInternal convolution_internal(string padding,
int[] strides,
int[] dilation_rate,
string name = null,
diff --git a/src/TensorFlowNET.Core/Tensorflow.Binding.csproj b/src/TensorFlowNET.Core/Tensorflow.Binding.csproj
index 3e881153..bc99a2dd 100644
--- a/src/TensorFlowNET.Core/Tensorflow.Binding.csproj
+++ b/src/TensorFlowNET.Core/Tensorflow.Binding.csproj
@@ -87,8 +87,4 @@ TensorFlow .NET v0.30 is focused on making more Keras API work including:
-
-
-
-
diff --git a/src/TensorFlowNET.Keras/Activations.cs b/src/TensorFlowNET.Keras/Activations.cs
deleted file mode 100644
index 5213fcb9..00000000
--- a/src/TensorFlowNET.Keras/Activations.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- class Activations
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Linear.cs b/src/TensorFlowNET.Keras/Activations/Activations.Linear.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Activations/Activations.Linear.cs
rename to src/TensorFlowNET.Keras/Activations/Activations.Linear.cs
diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Relu.cs b/src/TensorFlowNET.Keras/Activations/Activations.Relu.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Activations/Activations.Relu.cs
rename to src/TensorFlowNET.Keras/Activations/Activations.Relu.cs
diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Sigmoid.cs b/src/TensorFlowNET.Keras/Activations/Activations.Sigmoid.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Activations/Activations.Sigmoid.cs
rename to src/TensorFlowNET.Keras/Activations/Activations.Sigmoid.cs
diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Tanh.cs b/src/TensorFlowNET.Keras/Activations/Activations.Tanh.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Activations/Activations.Tanh.cs
rename to src/TensorFlowNET.Keras/Activations/Activations.Tanh.cs
diff --git a/src/TensorFlowNET.Keras/Applications/Densenet.cs b/src/TensorFlowNET.Keras/Applications/Densenet.cs
deleted file mode 100644
index a4cacc4a..00000000
--- a/src/TensorFlowNET.Keras/Applications/Densenet.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Densenet
- {
- public static Tensor dense_block(Tensor x, int blocks, string name) => throw new NotImplementedException();
-
- public static Tensor transition_block(Tensor x, float reduction, string name) => throw new NotImplementedException();
-
- public static Tensor conv_block(Tensor x, float growth_rate, string name) => throw new NotImplementedException();
-
- public static Model DenseNet(int blocks, bool include_top=true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model DenseNet121(int blocks, bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model DenseNet169(int blocks, bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model DenseNet201(int blocks, bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Efficientnet.cs b/src/TensorFlowNET.Keras/Applications/Efficientnet.cs
deleted file mode 100644
index 4b59bcee..00000000
--- a/src/TensorFlowNET.Keras/Applications/Efficientnet.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class BlockArg
- {
-
- }
-
- public class Efficientnet
- {
- public static Model EfficientNet(float width_coefficient, float depth_coefficient, int default_size, float dropout_rate = 0.2f,
- float drop_connect_rate = 0.2f, int depth_divisor = 8, string activation = "swish",
- BlockArg[] blocks_args = null, string model_name = "efficientnet", bool include_top = true,
- string weights = "imagenet", Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor block(Tensor inputs, string activation= "swish", float drop_rate= 0f,string name= "",
- int filters_in= 32, int filters_out= 16, int kernel_size= 3, int strides= 1,
- int expand_ratio= 1, float se_ratio= 0, bool id_skip= true) => throw new NotImplementedException();
-
- public static Model EfficientNetB0(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB1(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB2(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB3(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB4(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB5(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB6(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model EfficientNetB7(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/ImagenetUtils.cs b/src/TensorFlowNET.Keras/Applications/ImagenetUtils.cs
deleted file mode 100644
index 5e5df051..00000000
--- a/src/TensorFlowNET.Keras/Applications/ImagenetUtils.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class ImagenetUtils
- {
- public static Tensor preprocess_input(Tensor x, string data_format= null, string mode= "caffe") => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top= 5) => throw new NotImplementedException();
-
- public static Tensor _preprocess_numpy_input(Tensor x, string data_format, string mode) => throw new NotImplementedException();
-
- public static Tensor _preprocess_symbolic_input(Tensor x, string data_format, string mode) => throw new NotImplementedException();
-
- public static TensorShape obtain_input_shape(TensorShape input_shape, int default_size, int min_size,
- string data_format, bool require_flatten, string weights= null) => throw new NotImplementedException();
-
- public static ((int, int), (int, int)) correct_pad(Tensor inputs, (int, int) kernel_size) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/InceptionResnetV2.cs b/src/TensorFlowNET.Keras/Applications/InceptionResnetV2.cs
deleted file mode 100644
index bfc27f53..00000000
--- a/src/TensorFlowNET.Keras/Applications/InceptionResnetV2.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class InceptionResnetV2
- {
- public static Model InceptionResNetV2(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor conv2d_bn(Tensor x, int filters, (int, int) kernel_size, (int, int) strides, string padding= "same",
- string activation= "relu", bool use_bias= false, string name= null) => throw new NotImplementedException();
-
- public static Tensor inception_resnet_block(Tensor x, float scale, string block_type, int block_idx, string activation= "relu") => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/InceptionV3.cs b/src/TensorFlowNET.Keras/Applications/InceptionV3.cs
deleted file mode 100644
index 9b339e18..00000000
--- a/src/TensorFlowNET.Keras/Applications/InceptionV3.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class InceptionV3
- {
- public static Model Inceptionv3(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor conv2d_bn(Tensor x, int filters, int num_row, int num_col, string padding = "same", (int, int)? strides = null, string name = null) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Mobilenet.cs b/src/TensorFlowNET.Keras/Applications/Mobilenet.cs
deleted file mode 100644
index 65eb5db6..00000000
--- a/src/TensorFlowNET.Keras/Applications/Mobilenet.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Mobilenet
- {
- public static Model MobileNet(TensorShape input_shape= null, float alpha= 1.0f, int depth_multiplier= 1, float dropout= 1e-3f,
- bool include_top= true, string weights= "imagenet", Tensor input_tensor= null, string pooling= null, int classes= 1000) => throw new NotImplementedException();
-
- public static Tensor conv2d_bn(Tensor x, int filters, float alpha, (int, int)? kernel = null, (int, int)? strides = null) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/MobilenetV2.cs b/src/TensorFlowNET.Keras/Applications/MobilenetV2.cs
deleted file mode 100644
index a30c6c2a..00000000
--- a/src/TensorFlowNET.Keras/Applications/MobilenetV2.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class MobilenetV2
- {
- public static Model MobileNetV2(TensorShape input_shape = null, float alpha = 1.0f, bool include_top = true,
- string weights = "imagenet", Tensor input_tensor = null, string pooling = null,
- int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor _inverted_res_block(Tensor inputs, int expansion, (int, int) stride, float alpha, int filters, string block_id) => throw new NotImplementedException();
-
- public static Tensor _make_divisible(Tensor v, Tensor divisor, Tensor min_value= null) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Nasnet.cs b/src/TensorFlowNET.Keras/Applications/Nasnet.cs
deleted file mode 100644
index 9de5d3d9..00000000
--- a/src/TensorFlowNET.Keras/Applications/Nasnet.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Nasnet
- {
- public static Model NASNet(TensorShape input_shape = null, int penultimate_filters = 4032, int num_blocks = 6, int stem_block_filters = 96,
- bool skip_reduction = true, int filter_multiplier = 2, bool include_top = true, string weights = null,
- Tensor input_tensor = null, string pooling = null, int classes = 1000, int? default_size = null) => throw new NotImplementedException();
-
- public static Model NASNetMobile(TensorShape input_shape = null, bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model NASNetLarge(TensorShape input_shape = null, bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor _separable_conv_block(Tensor ip, int filters, (int, int)? kernel_size= null, (int, int)? strides= null, string block_id= null) => throw new NotImplementedException();
-
- public static Tensor _adjust_block(Tensor p, Tensor ip, int filters, string block_id= null) => throw new NotImplementedException();
-
- public static Tensor _normal_a_cell(Tensor p, Tensor ip, int filters, string block_id = null) => throw new NotImplementedException();
-
- public static Tensor _reduction_a_cell(Tensor p, Tensor ip, int filters, string block_id = null) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Resnet.cs b/src/TensorFlowNET.Keras/Applications/Resnet.cs
deleted file mode 100644
index 8154f404..00000000
--- a/src/TensorFlowNET.Keras/Applications/Resnet.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Resnet
- {
- public static Model ResNet(Func stack_fn, bool preact, bool use_bias, string model_name= "resnet", bool include_top= true,
- string weights= "imagenet", Tensor input_tensor= null, TensorShape input_shape= null, string pooling= null,
- int classes= 1000) => throw new NotImplementedException();
-
- public static Tensor block1(Tensor x, int filters, int kernel_size= 3, int stride= 1, bool conv_shortcut= true, string name= null) => throw new NotImplementedException();
-
- public static Tensor stack1(Tensor x, int filters, int blocks, int stride1 = 2, string name = null) => throw new NotImplementedException();
-
- public static Tensor block2(Tensor x, int filters, int kernel_size = 3, int stride = 1, bool conv_shortcut = true, string name = null) => throw new NotImplementedException();
-
- public static Tensor stack2(Tensor x, int filters, int blocks, int stride1 = 2, string name = null) => throw new NotImplementedException();
-
- public static Tensor block3(Tensor x, int filters, int kernel_size = 3, int stride = 1, int groups = 32, bool conv_shortcut = true, string name = null) => throw new NotImplementedException();
-
- public static Tensor stack3(Tensor x, int filters, int blocks, int stride1 = 2, int groups = 32, string name = null) => throw new NotImplementedException();
-
- public static Model ResNet50(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model ResNet101(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model ResNet152(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/ResnetV2.cs b/src/TensorFlowNET.Keras/Applications/ResnetV2.cs
deleted file mode 100644
index edb9df55..00000000
--- a/src/TensorFlowNET.Keras/Applications/ResnetV2.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class ResnetV2
- {
- public static Model ResNet50V2(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model ResNet101V2(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Model ResNet152V2(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Vgg16.cs b/src/TensorFlowNET.Keras/Applications/Vgg16.cs
deleted file mode 100644
index 8dcc1ce2..00000000
--- a/src/TensorFlowNET.Keras/Applications/Vgg16.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Vgg16
- {
- public static Model VGG16(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Vgg19.cs b/src/TensorFlowNET.Keras/Applications/Vgg19.cs
deleted file mode 100644
index 86e2969b..00000000
--- a/src/TensorFlowNET.Keras/Applications/Vgg19.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Vgg19
- {
- public static Model VGG19(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Applications/Xception.cs b/src/TensorFlowNET.Keras/Applications/Xception.cs
deleted file mode 100644
index fe400cfb..00000000
--- a/src/TensorFlowNET.Keras/Applications/Xception.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Applications
-{
- public class Xception
- {
- public static Model XCeption(bool include_top = true, string weights = "imagenet",
- Tensor input_tensor = null, TensorShape input_shape = null,
- string pooling = null, int classes = 1000) => throw new NotImplementedException();
-
- public static Tensor preprocess_input(Tensor x, string data_format = null) => throw new NotImplementedException();
-
- public static Tensor decode_predictions(Tensor preds, int top = 5) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Args.cs b/src/TensorFlowNET.Keras/Args.cs
deleted file mode 100644
index f2d9d27b..00000000
--- a/src/TensorFlowNET.Keras/Args.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Args
- {
- private List
///
///
- (string[], Dictionary>, List, Dictionary>) MapGraphNetwork(Tensors inputs, Tensors outputs)
+ (string[], Dictionary>, List, Dictionary>) MapGraphNetwork(Tensors inputs, Tensors outputs)
{
var (nodes_in_decreasing_depth, layer_indices) = BuildMap(outputs);
var network_nodes = nodes_in_decreasing_depth
.Select(node => MakeNodeKey(node.Layer.Name, node.Layer.InboundNodes.IndexOf(node)))
.ToArray();
- var nodes_depths = new Dictionary();
- var layers_depths = new Dictionary();
+ var nodes_depths = new Dictionary();
+ var layers_depths = new Dictionary();
nodes_in_decreasing_depth.Reverse();
foreach (var node in nodes_in_decreasing_depth)
@@ -200,19 +200,19 @@ namespace Tensorflow.Keras.Engine
}
// Build a dict {depth: list of nodes with this depth}
- var nodes_by_depth = new Dictionary>();
+ var nodes_by_depth = new Dictionary>();
foreach (var (node, depth) in enumerate(nodes_depths))
{
if (!nodes_by_depth.ContainsKey(depth))
- nodes_by_depth[depth] = new List();
+ nodes_by_depth[depth] = new List();
nodes_by_depth[depth].append(node);
}
- var layers_by_depth = new Dictionary>();
+ var layers_by_depth = new Dictionary>();
foreach (var (layer, depth) in enumerate(layers_depths))
{
if (!layers_by_depth.ContainsKey(depth))
- layers_by_depth[depth] = new List();
+ layers_by_depth[depth] = new List();
layers_by_depth[depth].append(layer);
}
@@ -220,7 +220,7 @@ namespace Tensorflow.Keras.Engine
var depth_keys = layers_by_depth.Keys.OrderBy(x => x).Reverse();
// Set self.layers ordered by depth.
- var layers = new List();
+ var layers = new List();
foreach (var depth in depth_keys)
{
var layers_for_depth = layers_by_depth[depth];
@@ -244,12 +244,12 @@ namespace Tensorflow.Keras.Engine
/// This method topologically sorts nodes in order from inputs to outputs.
///
///
- (List, Dictionary) BuildMap(Tensors outputs)
+ (List, Dictionary) BuildMap(Tensors outputs)
{
- var finished_nodes = new List();
- var nodes_in_progress = new List();
- var nodes_in_decreasing_depth = new List();
- var layer_indices = new Dictionary();
+ var finished_nodes = new List();
+ var nodes_in_progress = new List();
+ var nodes_in_decreasing_depth = new List();
+ var layer_indices = new Dictionary();
foreach (var output in outputs)
BuildMapHelper(output,
finished_nodes,
@@ -261,13 +261,13 @@ namespace Tensorflow.Keras.Engine
}
void BuildMapHelper(Tensor tensor,
- List finished_nodes,
- List nodes_in_progress,
- List nodes_in_decreasing_depth,
- Dictionary layer_indices)
+ List finished_nodes,
+ List nodes_in_progress,
+ List nodes_in_decreasing_depth,
+ Dictionary layer_indices)
{
var (layer, node_index, _) = tensor.KerasHistory;
- var node = layer.InboundNodes[node_index];
+ var node = layer.InboundNodes[node_index] as Node;
// Don't repeat work for shared subgraphs
if (finished_nodes.Contains(node))
@@ -327,7 +327,7 @@ namespace Tensorflow.Keras.Engine
foreach (var depth in depth_keys)
{
var nodes = NodesByDepth[depth];
- foreach (var node in nodes)
+ foreach (Node node in nodes)
{
// Input tensors already exist.
if (node.IsInput)
diff --git a/src/TensorFlowNET.Keras/Engine/InputLayer.cs b/src/TensorFlowNET.Keras/Engine/InputLayer.cs
deleted file mode 100644
index 3ed5f066..00000000
--- a/src/TensorFlowNET.Keras/Engine/InputLayer.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class InputLayer
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.AddWeights.cs b/src/TensorFlowNET.Keras/Engine/Layer.AddWeights.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.AddWeights.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.AddWeights.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.Apply.cs b/src/TensorFlowNET.Keras/Engine/Layer.Apply.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.Apply.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.Apply.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs b/src/TensorFlowNET.Keras/Engine/Layer.FlattenLayers.cs
similarity index 76%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.FlattenLayers.cs
index 1759b17d..e088fdaf 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs
+++ b/src/TensorFlowNET.Keras/Engine/Layer.FlattenLayers.cs
@@ -4,13 +4,13 @@ namespace Tensorflow.Keras.Engine
{
public partial class Layer
{
- public IEnumerable _flatten_layers(bool recursive = true, bool include_self = true)
+ public IEnumerable _flatten_layers(bool recursive = true, bool include_self = true)
{
if (include_self)
yield return this;
var seen_object_ids = new List();
- var deque = new Queue(_layers);
+ var deque = new Queue(_layers);
while (!deque.empty())
{
var layer_or_container = deque.Dequeue();
@@ -20,7 +20,7 @@ namespace Tensorflow.Keras.Engine
seen_object_ids.Add(layer_or_container_id);
yield return layer_or_container;
if (recursive)
- deque.extendleft(layer_or_container._layers);
+ deque.extendleft(layer_or_container.Layers);
}
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.FunctionalConstructionCall.cs b/src/TensorFlowNET.Keras/Engine/Layer.FunctionalConstructionCall.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.FunctionalConstructionCall.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.FunctionalConstructionCall.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs b/src/TensorFlowNET.Keras/Engine/Layer.Layers.cs
similarity index 51%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.Layers.cs
index 9a0520a0..dcbfa1e6 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs
+++ b/src/TensorFlowNET.Keras/Engine/Layer.Layers.cs
@@ -4,10 +4,10 @@ namespace Tensorflow.Keras.Engine
{
public partial class Layer
{
- protected List _layers = new List();
- public List Layers => _layers;
+ protected List _layers = new List();
+ public List Layers => _layers;
- protected void StackLayers(params Layer[] layers)
+ protected void StackLayers(params ILayer[] layers)
{
_layers.AddRange(layers);
}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.LoadWeights.cs b/src/TensorFlowNET.Keras/Engine/Layer.LoadWeights.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.LoadWeights.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.LoadWeights.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs b/src/TensorFlowNET.Keras/Engine/Layer.State.cs
similarity index 69%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.State.cs
index 43a72c36..35f1a852 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs
+++ b/src/TensorFlowNET.Keras/Engine/Layer.State.cs
@@ -5,16 +5,16 @@ namespace Tensorflow.Keras.Engine
{
public partial class Layer
{
- protected Dictionary trainable_state;
- protected Dictionary _compiled_trainable_state;
+ protected Dictionary trainable_state;
+ protected Dictionary _compiled_trainable_state;
///
/// Get the `trainable` state of each sublayer.
///
///
- protected Dictionary _get_trainable_state()
+ protected Dictionary _get_trainable_state()
{
- trainable_state = new Dictionary();
+ trainable_state = new Dictionary();
foreach (var layer in _flatten_layers())
trainable_state[layer] = layer.Trainable;
return trainable_state;
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.cs b/src/TensorFlowNET.Keras/Engine/Layer.cs
similarity index 94%
rename from src/TensorFlowNET.Core/Keras/Engine/Layer.cs
rename to src/TensorFlowNET.Keras/Engine/Layer.cs
index 4e5dc45d..0c892535 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/Layer.cs
+++ b/src/TensorFlowNET.Keras/Engine/Layer.cs
@@ -31,7 +31,7 @@ namespace Tensorflow.Keras.Engine
/// as convolution, batch norm, etc. These operations require managing weights,
/// losses, updates, and inter-layer connectivity.
///
- public abstract partial class Layer : AutoTrackable
+ public abstract partial class Layer : AutoTrackable, ILayer
{
///
/// Arguments initialize layer.
@@ -72,16 +72,16 @@ namespace Tensorflow.Keras.Engine
protected List updates;
public TensorShape BatchInputShape => args.BatchInputShape;
- List inboundNodes;
- public List InboundNodes => inboundNodes;
+ List inboundNodes;
+ public List InboundNodes => inboundNodes;
- List outboundNodes;
- public List OutboundNodes => outboundNodes;
+ List outboundNodes;
+ public List OutboundNodes => outboundNodes;
ThreadLocal callContext;
public CallContext CallContext => callContext.Value;
public Tensor[] input => inboundNodes[0].input_tensors;
- public Dictionary> NodesByDepth { get; set; }
+ public Dictionary> NodesByDepth { get; set; }
public TensorShape output_shape => inboundNodes[0].Outputs.shape;
public Layer(LayerArgs args)
{
@@ -100,8 +100,8 @@ namespace Tensorflow.Keras.Engine
computePreviousMask = false;
updates = new List();
- inboundNodes = new List();
- outboundNodes = new List();
+ inboundNodes = new List();
+ outboundNodes = new List();
// Manage input shape information if passed.
if (args.BatchInputShape == null && args.InputShape != null)
diff --git a/src/TensorFlowNET.Core/Keras/Engine/LossesContainer.cs b/src/TensorFlowNET.Keras/Engine/LossesContainer.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/LossesContainer.cs
rename to src/TensorFlowNET.Keras/Engine/LossesContainer.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs b/src/TensorFlowNET.Keras/Engine/MetricsContainer.cs
similarity index 95%
rename from src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs
rename to src/TensorFlowNET.Keras/Engine/MetricsContainer.cs
index 990f15ca..3eb780fc 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs
+++ b/src/TensorFlowNET.Keras/Engine/MetricsContainer.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Tensorflow.Keras.Metrics;
using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras.Engine
{
@@ -60,7 +61,7 @@ namespace Tensorflow.Keras.Engine
Func metric_obj = null;
if (metric == "accuracy" || metric == "acc")
{
- metric_obj = tf.keras.metrics.sparse_categorical_accuracy;
+ metric_obj = keras.metrics.sparse_categorical_accuracy;
return new MeanMetricWrapper(metric_obj, metric);
}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Compile.cs b/src/TensorFlowNET.Keras/Engine/Model.Compile.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.Compile.cs
rename to src/TensorFlowNET.Keras/Engine/Model.Compile.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Fit.cs b/src/TensorFlowNET.Keras/Engine/Model.Fit.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.Fit.cs
rename to src/TensorFlowNET.Keras/Engine/Model.Fit.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Metrics.cs b/src/TensorFlowNET.Keras/Engine/Model.Metrics.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.Metrics.cs
rename to src/TensorFlowNET.Keras/Engine/Model.Metrics.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Predict.cs b/src/TensorFlowNET.Keras/Engine/Model.Predict.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.Predict.cs
rename to src/TensorFlowNET.Keras/Engine/Model.Predict.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Summary.cs b/src/TensorFlowNET.Keras/Engine/Model.Summary.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.Summary.cs
rename to src/TensorFlowNET.Keras/Engine/Model.Summary.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Train.cs b/src/TensorFlowNET.Keras/Engine/Model.Train.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.Train.cs
rename to src/TensorFlowNET.Keras/Engine/Model.Train.cs
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.cs b/src/TensorFlowNET.Keras/Engine/Model.cs
similarity index 98%
rename from src/TensorFlowNET.Core/Keras/Engine/Model.cs
rename to src/TensorFlowNET.Keras/Engine/Model.cs
index fe53d52a..eac7a139 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/Model.cs
+++ b/src/TensorFlowNET.Keras/Engine/Model.cs
@@ -10,7 +10,7 @@ namespace Tensorflow.Keras.Engine
///
/// `Model` groups layers into an object with training and inference features.
///
- public partial class Model : Layer
+ public partial class Model : Layer, IModel
{
#pragma warning disable CS0169 // The field 'Model._cloning' is never used
bool _cloning;
diff --git a/src/TensorFlowNET.Keras/Engine/Network.cs b/src/TensorFlowNET.Keras/Engine/Network.cs
deleted file mode 100644
index f9470f8b..00000000
--- a/src/TensorFlowNET.Keras/Engine/Network.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class Network
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs b/src/TensorFlowNET.Keras/Engine/Node.IterateInbound.cs
similarity index 82%
rename from src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs
rename to src/TensorFlowNET.Keras/Engine/Node.IterateInbound.cs
index d18fc8cc..359d36c9 100644
--- a/src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs
+++ b/src/TensorFlowNET.Keras/Engine/Node.IterateInbound.cs
@@ -4,7 +4,7 @@ namespace Tensorflow.Keras.Engine
{
public partial class Node
{
- public IEnumerable<(Layer, int, int, Tensor)> iterate_inbound()
+ public IEnumerable<(ILayer, int, int, Tensor)> iterate_inbound()
{
foreach (var kt in KerasInputs)
{
diff --git a/src/TensorFlowNET.Keras/Engine/Node.cs b/src/TensorFlowNET.Keras/Engine/Node.cs
index d74e98b6..1601a6a6 100644
--- a/src/TensorFlowNET.Keras/Engine/Node.cs
+++ b/src/TensorFlowNET.Keras/Engine/Node.cs
@@ -1,10 +1,121 @@
-using System;
+/*****************************************************************************
+ Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+******************************************************************************/
+
using System.Collections.Generic;
-using System.Text;
+using System.Linq;
+using Tensorflow.Keras.ArgsDefinition;
+using static Tensorflow.Binding;
namespace Tensorflow.Keras.Engine
{
- public class Node
+ ///
+ /// A `Node` describes the connectivity between two layers.
+ ///
+ /// Each time a layer is connected to some new input,
+ /// a node is added to `layer._inbound_nodes`.
+ /// Each time the output of a layer is used by another layer,
+ /// a node is added to `layer._outbound_nodes`.
+ ///
+ public partial class Node : INode
{
+ NodeArgs args;
+
+ public int[] node_indices;
+ public int[] tensor_indices;
+ public Tensors input_tensors => args.InputTensors;
+ public Tensors Outputs => args.Outputs;
+ public TensorShape[] input_shapes;
+ public TensorShape[] output_shapes;
+ public List KerasInputs { get; set; } = new List();
+ public ILayer Layer { get; set; }
+ public bool IsInput => args.InputTensors == null;
+ public int[] FlatInputIds { get; set; }
+ public int[] FlatOutputIds { get; set; }
+ bool _single_positional_tensor_passed => KerasInputs.Count() == 1;
+ Dictionary _keras_inputs_ids_and_indices = new Dictionary();
+ public INode[] ParentNodes
+ {
+ get
+ {
+ var node_deps = new List();
+ foreach (var kt in KerasInputs)
+ {
+ var (layer, node_index, _) = kt.KerasHistory;
+ if (layer != null)
+ node_deps.append(layer.InboundNodes[node_index]);
+ }
+ return node_deps.ToArray();
+ }
+ }
+
+ public Node(Layer layer, NodeArgs args)
+ {
+ this.args = args;
+ this.Layer = layer;
+
+ if (args.InputTensors != null)
+ KerasInputs.AddRange(args.InputTensors);
+
+ foreach (var (i, ele) in enumerate(KerasInputs))
+ _keras_inputs_ids_and_indices[i] = ele.GetHashCode();
+
+ // Wire up Node to Layers.
+ layer.InboundNodes.Add(this);
+ foreach (var kt in KerasInputs)
+ {
+ if (kt.KerasHistory == null)
+ continue;
+ var (inbound_layer, _, _) = kt.KerasHistory;
+ if (inbound_layer != null)
+ inbound_layer.OutboundNodes.Add(this);
+ }
+
+ // Set metadata on outputs.
+ var node_index = layer.InboundNodes.Count - 1;
+ foreach (var (i, tensor) in enumerate(Outputs))
+ tensor.KerasHistory = new KerasHistory(layer, node_index, i, tensor);
+
+ // Cached for performance.
+ FlatInputIds = KerasInputs.Select(x => x.GetHashCode()).ToArray();
+ FlatOutputIds = Outputs.Select(x => x.GetHashCode()).ToArray();
+ }
+
+ ///
+ /// Maps Keras Tensors to computed Tensors using `tensor_dict`.
+ ///
+ ///
+ ///
+ public Tensors MapArguments(Dictionary> tensor_dict)
+ {
+ if (_single_positional_tensor_passed)
+ {
+ var kt_id = _keras_inputs_ids_and_indices[0];
+ return tensor_dict[kt_id].Dequeue();
+ }
+ else
+ {
+ var flat_arguments = KerasInputs.Select(x => x).ToArray();
+ foreach (var (kt_index, kt_id) in enumerate(_keras_inputs_ids_and_indices))
+ flat_arguments[kt_index] = tensor_dict[kt_id].Dequeue();
+
+ return flat_arguments;
+ }
+ }
+
+ public override string ToString()
+ => $"{Layer.Name}, {KerasInputs.Count} inputs: {string.Join(",", KerasInputs.Select(x => x.name))}";
}
}
diff --git a/src/TensorFlowNET.Keras/Engine/PartialBatchPaddingHandler.cs b/src/TensorFlowNET.Keras/Engine/PartialBatchPaddingHandler.cs
deleted file mode 100644
index 422ae27e..00000000
--- a/src/TensorFlowNET.Keras/Engine/PartialBatchPaddingHandler.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class PartialBatchPaddingHandler
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/Sequential.cs b/src/TensorFlowNET.Keras/Engine/Sequential.cs
index 611ab18b..5fe2f5b0 100644
--- a/src/TensorFlowNET.Keras/Engine/Sequential.cs
+++ b/src/TensorFlowNET.Keras/Engine/Sequential.cs
@@ -1,11 +1,135 @@
-using System;
+/*****************************************************************************
+ Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+******************************************************************************/
+
using System.Collections.Generic;
-using System.Text;
+using Tensorflow.Keras.ArgsDefinition;
+using Tensorflow.Keras.Layers;
+using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras.Engine
{
- public class Sequential
+ ///
+ /// `Sequential` groups a linear stack of layers into a `tf.keras.Model`.
+ /// `Sequential` provides training and inference features on this model.
+ ///
+ public class Sequential : Model
{
-
+ SequentialArgs args;
+ bool _is_graph_network;
+ Tensor inputs;
+ Tensor outputs;
+
+ bool computeOutputAndMaskJointly;
+ bool autoTrackSubLayers;
+ TensorShape inferredInputShape;
+ bool hasExplicitInputShape;
+ TF_DataType inputDType;
+ List layers => args.Layers;
+ public TensorShape output_shape => outputs.TensorShape;
+ bool built = false;
+
+ public Sequential(SequentialArgs args)
+ : base(new ModelArgs
+ {
+ Name = args.Name
+ })
+ {
+ this.args = args;
+ if (args.Layers == null)
+ args.Layers = new List();
+ // SupportsMasking = true;
+ computeOutputAndMaskJointly = true;
+ autoTrackSubLayers = false;
+ hasExplicitInputShape = false;
+ _is_graph_network = false;
+ }
+
+ public void add(Tensor tensor)
+ {
+ var layer = tensor.KerasHistory.Layer as Layer;
+ add(layer);
+ }
+
+ ///
+ /// Adds a layer instance on top of the layer stack.
+ ///
+ ///
+ public void add(Layer layer)
+ {
+ built = false;
+ var set_inputs = false;
+ if (layers.Count == 0)
+ {
+ if (layer is InputLayer)
+ {
+ set_inputs = true;
+ }
+ else
+ {
+ if (layer.BatchInputShape != null)
+ {
+ // Instantiate an input layer.
+ var x = keras.Input(
+ shape: layer.BatchInputShape,
+ dtype: layer.DType,
+ name: layer.Name + "_input");
+
+ // This will build the current layer
+ // and create the node connecting the current layer
+ // to the input layer we just created.
+ layer.Apply(x);
+ set_inputs = true;
+ }
+ }
+
+ if (set_inputs)
+ {
+ // If an input layer (placeholder) is available.
+ outputs = layer.InboundNodes[^1].Outputs;
+ }
+
+ }
+ else if (outputs != null)
+ {
+ outputs = layer.Apply(outputs);
+ }
+
+ if (set_inputs || _is_graph_network)
+ {
+ _init_graph_network(inputs, outputs);
+ }
+ else
+ {
+
+ }
+ }
+
+ void _init_graph_network(Tensor inputs, Tensor outputs)
+ {
+ _is_graph_network = true;
+ this.inputs = inputs;
+ this.outputs = outputs;
+ built = true;
+ _map_graph_network(inputs, outputs);
+ }
+
+ void _map_graph_network(Tensor inputs, Tensor outputs)
+ {
+ layers.add(outputs.KerasHistory.Layer);
+ }
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Engine/TensorFlowOpLayer.cs b/src/TensorFlowNET.Keras/Engine/TensorFlowOpLayer.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Engine/TensorFlowOpLayer.cs
rename to src/TensorFlowNET.Keras/Engine/TensorFlowOpLayer.cs
diff --git a/src/TensorFlowNET.Keras/Engine/TrackableWeightHandler.cs b/src/TensorFlowNET.Keras/Engine/TrackableWeightHandler.cs
deleted file mode 100644
index c6305809..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrackableWeightHandler.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- public class TrackableWeightHandler
- {
- public int num_tensors
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public TrackableWeightHandler(bool trackable)
- {
- throw new NotImplementedException();
- }
-
- public void set_weights(Tensor[] weights) => throw new NotImplementedException();
-
- public void _set_weights_v1(Tensor[] weights) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/Training.cs b/src/TensorFlowNET.Keras/Engine/Training.cs
deleted file mode 100644
index 64a9d5ba..00000000
--- a/src/TensorFlowNET.Keras/Engine/Training.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- public class Training
- {
- public class Model
- {
-
- }
-
- public class _TrainingEndpoint
- {
-
- }
-
- public class _TrainingTarget
- {
-
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingArrays.cs b/src/TensorFlowNET.Keras/Engine/TrainingArrays.cs
deleted file mode 100644
index ca340631..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingArrays.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingArrays
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingDistributed.cs b/src/TensorFlowNET.Keras/Engine/TrainingDistributed.cs
deleted file mode 100644
index 3eef4c6c..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingDistributed.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingDistributed
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingEager.cs b/src/TensorFlowNET.Keras/Engine/TrainingEager.cs
deleted file mode 100644
index a697bdae..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingEager.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingEager
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingGenerator.cs b/src/TensorFlowNET.Keras/Engine/TrainingGenerator.cs
deleted file mode 100644
index 5b241890..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingGenerator.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingGenerator
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingUtils.cs b/src/TensorFlowNET.Keras/Engine/TrainingUtils.cs
deleted file mode 100644
index 913fa688..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingV1.cs b/src/TensorFlowNET.Keras/Engine/TrainingV1.cs
deleted file mode 100644
index 7dee23ea..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingV1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingV1
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingV2.cs b/src/TensorFlowNET.Keras/Engine/TrainingV2.cs
deleted file mode 100644
index 47d11694..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Engine/TrainingV2Utils.cs b/src/TensorFlowNET.Keras/Engine/TrainingV2Utils.cs
deleted file mode 100644
index 9122a005..00000000
--- a/src/TensorFlowNET.Keras/Engine/TrainingV2Utils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Engine
-{
- class TrainingV2Utils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Estimator.cs b/src/TensorFlowNET.Keras/Estimator.cs
deleted file mode 100644
index fec0f8e5..00000000
--- a/src/TensorFlowNET.Keras/Estimator.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- class Estimator
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/GraphLearningPhase.cs b/src/TensorFlowNET.Keras/GraphLearningPhase.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/GraphLearningPhase.cs
rename to src/TensorFlowNET.Keras/GraphLearningPhase.cs
diff --git a/src/TensorFlowNET.Core/Keras/ImageDataFormat.cs b/src/TensorFlowNET.Keras/ImageDataFormat.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/ImageDataFormat.cs
rename to src/TensorFlowNET.Keras/ImageDataFormat.cs
diff --git a/src/TensorFlowNET.Core/Keras/Initializers.cs b/src/TensorFlowNET.Keras/Initializers.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Initializers.cs
rename to src/TensorFlowNET.Keras/Initializers.cs
diff --git a/src/TensorFlowNET.Keras/Initializers/Constant.cs b/src/TensorFlowNET.Keras/Initializers/Constant.cs
deleted file mode 100644
index 9d942100..00000000
--- a/src/TensorFlowNET.Keras/Initializers/Constant.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class Constant
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/ConstantV2.cs b/src/TensorFlowNET.Keras/Initializers/ConstantV2.cs
deleted file mode 100644
index 7622596c..00000000
--- a/src/TensorFlowNET.Keras/Initializers/ConstantV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class ConstantV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/GlorotNormal.cs b/src/TensorFlowNET.Keras/Initializers/GlorotNormal.cs
deleted file mode 100644
index 47e84837..00000000
--- a/src/TensorFlowNET.Keras/Initializers/GlorotNormal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class GlorotNormal
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/GlorotNormalV2.cs b/src/TensorFlowNET.Keras/Initializers/GlorotNormalV2.cs
deleted file mode 100644
index 2c00cbdc..00000000
--- a/src/TensorFlowNET.Keras/Initializers/GlorotNormalV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class GlorotNormalV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/GlorotUniform.cs b/src/TensorFlowNET.Keras/Initializers/GlorotUniform.cs
deleted file mode 100644
index f3d7d785..00000000
--- a/src/TensorFlowNET.Keras/Initializers/GlorotUniform.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class GlorotUniform
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/GlorotUniformV2.cs b/src/TensorFlowNET.Keras/Initializers/GlorotUniformV2.cs
deleted file mode 100644
index 67d9a975..00000000
--- a/src/TensorFlowNET.Keras/Initializers/GlorotUniformV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class GlorotUniformV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/HeNormal.cs b/src/TensorFlowNET.Keras/Initializers/HeNormal.cs
deleted file mode 100644
index 1ec4b282..00000000
--- a/src/TensorFlowNET.Keras/Initializers/HeNormal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class HeNormal
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/HeNormalV2.cs b/src/TensorFlowNET.Keras/Initializers/HeNormalV2.cs
deleted file mode 100644
index 5450898b..00000000
--- a/src/TensorFlowNET.Keras/Initializers/HeNormalV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class HeNormalV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/HeUniform.cs b/src/TensorFlowNET.Keras/Initializers/HeUniform.cs
deleted file mode 100644
index d07cf932..00000000
--- a/src/TensorFlowNET.Keras/Initializers/HeUniform.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class HeUniform
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/HeUniformV2.cs b/src/TensorFlowNET.Keras/Initializers/HeUniformV2.cs
deleted file mode 100644
index 0dbcb678..00000000
--- a/src/TensorFlowNET.Keras/Initializers/HeUniformV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class HeUniformV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/Identity.cs b/src/TensorFlowNET.Keras/Initializers/Identity.cs
deleted file mode 100644
index 178d70e5..00000000
--- a/src/TensorFlowNET.Keras/Initializers/Identity.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class Identity
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/IdentityV2.cs b/src/TensorFlowNET.Keras/Initializers/IdentityV2.cs
deleted file mode 100644
index 5955d41e..00000000
--- a/src/TensorFlowNET.Keras/Initializers/IdentityV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class IdentityV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/Initializer.cs b/src/TensorFlowNET.Keras/Initializers/Initializer.cs
deleted file mode 100644
index 5a432be1..00000000
--- a/src/TensorFlowNET.Keras/Initializers/Initializer.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- public abstract class Initializer
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/InitializerV2.cs b/src/TensorFlowNET.Keras/Initializers/InitializerV2.cs
deleted file mode 100644
index 638785d9..00000000
--- a/src/TensorFlowNET.Keras/Initializers/InitializerV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class InitializerV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/LecunNormal.cs b/src/TensorFlowNET.Keras/Initializers/LecunNormal.cs
deleted file mode 100644
index a810dfa8..00000000
--- a/src/TensorFlowNET.Keras/Initializers/LecunNormal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class LecunNormal
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/LecunNormalV2.cs b/src/TensorFlowNET.Keras/Initializers/LecunNormalV2.cs
deleted file mode 100644
index 5010ddde..00000000
--- a/src/TensorFlowNET.Keras/Initializers/LecunNormalV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class LecunNormalV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/LecunUniform.cs b/src/TensorFlowNET.Keras/Initializers/LecunUniform.cs
deleted file mode 100644
index 96bfb4d4..00000000
--- a/src/TensorFlowNET.Keras/Initializers/LecunUniform.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class LecunUniform
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/LecunUniformV2.cs b/src/TensorFlowNET.Keras/Initializers/LecunUniformV2.cs
deleted file mode 100644
index 0eb24dd1..00000000
--- a/src/TensorFlowNET.Keras/Initializers/LecunUniformV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class LecunUniformV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/Ones.cs b/src/TensorFlowNET.Keras/Initializers/Ones.cs
deleted file mode 100644
index e30399bb..00000000
--- a/src/TensorFlowNET.Keras/Initializers/Ones.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class Ones
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/OnesV2.cs b/src/TensorFlowNET.Keras/Initializers/OnesV2.cs
deleted file mode 100644
index 18b6ee9a..00000000
--- a/src/TensorFlowNET.Keras/Initializers/OnesV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class OnesV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/Orthogonal.cs b/src/TensorFlowNET.Keras/Initializers/Orthogonal.cs
deleted file mode 100644
index 984d986b..00000000
--- a/src/TensorFlowNET.Keras/Initializers/Orthogonal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class Orthogonal
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/OrthogonalV2.cs b/src/TensorFlowNET.Keras/Initializers/OrthogonalV2.cs
deleted file mode 100644
index eedddeb7..00000000
--- a/src/TensorFlowNET.Keras/Initializers/OrthogonalV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class OrthogonalV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/RandomNormal.cs b/src/TensorFlowNET.Keras/Initializers/RandomNormal.cs
deleted file mode 100644
index 0efe8cb9..00000000
--- a/src/TensorFlowNET.Keras/Initializers/RandomNormal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class RandomNormal
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/RandomNormalV2.cs b/src/TensorFlowNET.Keras/Initializers/RandomNormalV2.cs
deleted file mode 100644
index e1bd3606..00000000
--- a/src/TensorFlowNET.Keras/Initializers/RandomNormalV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class RandomNormalV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/RandomUniform.cs b/src/TensorFlowNET.Keras/Initializers/RandomUniform.cs
deleted file mode 100644
index 4547957e..00000000
--- a/src/TensorFlowNET.Keras/Initializers/RandomUniform.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class RandomUniform
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/RandomUniformV2.cs b/src/TensorFlowNET.Keras/Initializers/RandomUniformV2.cs
deleted file mode 100644
index 678c27d0..00000000
--- a/src/TensorFlowNET.Keras/Initializers/RandomUniformV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class RandomUniformV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/TruncatedNormal.cs b/src/TensorFlowNET.Keras/Initializers/TruncatedNormal.cs
deleted file mode 100644
index 2ba845d8..00000000
--- a/src/TensorFlowNET.Keras/Initializers/TruncatedNormal.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class TruncatedNormal
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/TruncatedNormalV2.cs b/src/TensorFlowNET.Keras/Initializers/TruncatedNormalV2.cs
deleted file mode 100644
index 2b90b396..00000000
--- a/src/TensorFlowNET.Keras/Initializers/TruncatedNormalV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class TruncatedNormalV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/VarianceScaling.cs b/src/TensorFlowNET.Keras/Initializers/VarianceScaling.cs
deleted file mode 100644
index 7d09e46a..00000000
--- a/src/TensorFlowNET.Keras/Initializers/VarianceScaling.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class VarianceScaling
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/VarianceScalingV2.cs b/src/TensorFlowNET.Keras/Initializers/VarianceScalingV2.cs
deleted file mode 100644
index d9fd9f23..00000000
--- a/src/TensorFlowNET.Keras/Initializers/VarianceScalingV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class VarianceScalingV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/Zeros.cs b/src/TensorFlowNET.Keras/Initializers/Zeros.cs
deleted file mode 100644
index dd976c88..00000000
--- a/src/TensorFlowNET.Keras/Initializers/Zeros.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class Zeros
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Initializers/ZerosV2.cs b/src/TensorFlowNET.Keras/Initializers/ZerosV2.cs
deleted file mode 100644
index 00da7715..00000000
--- a/src/TensorFlowNET.Keras/Initializers/ZerosV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Initializers
-{
- class ZerosV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/KerasApi.cs b/src/TensorFlowNET.Keras/KerasApi.cs
similarity index 94%
rename from src/TensorFlowNET.Core/Keras/KerasApi.cs
rename to src/TensorFlowNET.Keras/KerasApi.cs
index 5d2f15af..cdf22117 100644
--- a/src/TensorFlowNET.Core/Keras/KerasApi.cs
+++ b/src/TensorFlowNET.Keras/KerasApi.cs
@@ -1,5 +1,6 @@
-using System.Collections.Generic;
-using Tensorflow.Keras;
+using System;
+using System.Collections.Generic;
+using System.Text;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Datasets;
using Tensorflow.Keras.Engine;
@@ -8,7 +9,7 @@ using Tensorflow.Keras.Losses;
using Tensorflow.Keras.Metrics;
using Tensorflow.Keras.Optimizers;
-namespace Tensorflow
+namespace Tensorflow.Keras
{
public class KerasApi
{
@@ -23,7 +24,7 @@ namespace Tensorflow
public OptimizerApi optimizers { get; } = new OptimizerApi();
public MetricsApi metrics { get; } = new MetricsApi();
- public Sequential Sequential(List layers = null,
+ public Sequential Sequential(List layers = null,
string name = null)
=> new Sequential(new SequentialArgs
{
diff --git a/src/TensorFlowNET.Keras/KerasExtension.cs b/src/TensorFlowNET.Keras/KerasExtension.cs
new file mode 100644
index 00000000..d55b294a
--- /dev/null
+++ b/src/TensorFlowNET.Keras/KerasExtension.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tensorflow.Keras;
+
+namespace Tensorflow
+{
+ public static class KerasExt
+ {
+ public static KerasApi Keras(this tensorflow tf)
+ => new KerasApi();
+
+ public static KerasApi keras { get; } = new KerasApi();
+ }
+}
diff --git a/src/TensorFlowNET.Keras/KerasParameterized.cs b/src/TensorFlowNET.Keras/KerasParameterized.cs
deleted file mode 100644
index f5d65541..00000000
--- a/src/TensorFlowNET.Keras/KerasParameterized.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- class KerasParameterized
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/KwArgs.cs b/src/TensorFlowNET.Keras/KwArgs.cs
deleted file mode 100644
index 11a90dd8..00000000
--- a/src/TensorFlowNET.Keras/KwArgs.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class KwArgs
- {
- private Dictionary args = new Dictionary();
-
- public object this[string name]
- {
- get
- {
- return args.ContainsKey(name) ? args[name] : null;
- }
- set
- {
- args[name] = value;
- }
- }
-
- public T Get(string name)
- {
- if (!args.ContainsKey(name))
- return default(T);
-
- return (T)args[name];
- }
-
- public static explicit operator KwArgs(ValueTuple[] p)
- {
- KwArgs kwArgs = new KwArgs();
- kwArgs.args = new Dictionary();
- foreach (var item in p)
- {
- kwArgs.args[item.Item1] = item.Item2;
- }
-
- return kwArgs;
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ELU.cs b/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ELU.cs
deleted file mode 100644
index bf8e7c90..00000000
--- a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ELU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.AdvancedActivations
-{
- class ELU
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/LeakyReLU.cs b/src/TensorFlowNET.Keras/Layers/AdvancedActivations/LeakyReLU.cs
deleted file mode 100644
index d56203a2..00000000
--- a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/LeakyReLU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.AdvancedActivations
-{
- class LeakyReLU
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/PReLU.cs b/src/TensorFlowNET.Keras/Layers/AdvancedActivations/PReLU.cs
deleted file mode 100644
index 7cb2e20c..00000000
--- a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/PReLU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.AdvancedActivations
-{
- class PReLU
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ReLU.cs b/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ReLU.cs
deleted file mode 100644
index 77ee3994..00000000
--- a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ReLU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.AdvancedActivations
-{
- class ReLU
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/Softmax.cs b/src/TensorFlowNET.Keras/Layers/AdvancedActivations/Softmax.cs
deleted file mode 100644
index 694e75a7..00000000
--- a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/Softmax.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.AdvancedActivations
-{
- class Softmax
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ThresholdedReLU.cs b/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ThresholdedReLU.cs
deleted file mode 100644
index a5b849ca..00000000
--- a/src/TensorFlowNET.Keras/Layers/AdvancedActivations/ThresholdedReLU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.AdvancedActivations
-{
- class ThresholdedReLU
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs b/src/TensorFlowNET.Keras/Layers/BatchNormalization.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs
rename to src/TensorFlowNET.Keras/Layers/BatchNormalization.cs
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Conv2D.cs b/src/TensorFlowNET.Keras/Layers/Conv2D.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Conv2D.cs
rename to src/TensorFlowNET.Keras/Layers/Conv2D.cs
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Convolutional.cs b/src/TensorFlowNET.Keras/Layers/Convolutional.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Convolutional.cs
rename to src/TensorFlowNET.Keras/Layers/Convolutional.cs
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Conv.cs
deleted file mode 100644
index f7e6950f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Conv
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv1D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Conv1D.cs
deleted file mode 100644
index 91c1a987..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Conv1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv2D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Conv2D.cs
deleted file mode 100644
index a82f89eb..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Conv2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv2DTranspose.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Conv2DTranspose.cs
deleted file mode 100644
index 2c16bc98..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv2DTranspose.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Conv2DTranspose
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv3D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Conv3D.cs
deleted file mode 100644
index 4177dbed..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Conv3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv3DTranspose.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Conv3DTranspose.cs
deleted file mode 100644
index 1537d48e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Conv3DTranspose.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Conv3DTranspose
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping1D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping1D.cs
deleted file mode 100644
index 5edfea70..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Cropping1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping2D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping2D.cs
deleted file mode 100644
index e3f99bfd..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Cropping2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping3D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping3D.cs
deleted file mode 100644
index e702cfef..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/Cropping3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Cropping3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Convolutional/DepthwiseConv2D.cs b/src/TensorFlowNET.Keras/Layers/Convolutional/DepthwiseConv2D.cs
deleted file mode 100644
index 53e9271d..00000000
--- a/src/TensorFlowNET.Keras/Layers/Convolutional/DepthwiseConv2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class DepthwiseConv2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvLSTM2D.cs b/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvLSTM2D.cs
deleted file mode 100644
index f8d27d27..00000000
--- a/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvLSTM2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class ConvLSTM2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvLSTM2DCell.cs b/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvLSTM2DCell.cs
deleted file mode 100644
index 86195574..00000000
--- a/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvLSTM2DCell.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class ConvLSTM2DCell
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvRNN2D.cs b/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvRNN2D.cs
deleted file mode 100644
index 420c2444..00000000
--- a/src/TensorFlowNET.Keras/Layers/ConvolutionalRecurrent/ConvRNN2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class ConvRNN2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Activation.cs b/src/TensorFlowNET.Keras/Layers/Core/Activation.cs
deleted file mode 100644
index 03f4e8f1..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Activation.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Activation
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/ActivityRegularization.cs b/src/TensorFlowNET.Keras/Layers/Core/ActivityRegularization.cs
deleted file mode 100644
index d88d53d5..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/ActivityRegularization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class ActivityRegularization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Dense.cs b/src/TensorFlowNET.Keras/Layers/Core/Dense.cs
deleted file mode 100644
index 00885f1f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Dense.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-/*****************************************************************************
- Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using System;
-using Tensorflow;
-using static Keras.Keras;
-using NumSharp;
-using Tensorflow.Operations.Activation;
-using static Tensorflow.Binding;
-
-namespace Keras.Layers
-{
- public class Dense : Layer
- {
- RefVariable W;
- int units;
- TensorShape WShape;
-#pragma warning disable CS0108 // Member hides inherited member; missing new keyword
- string name;
-#pragma warning restore CS0108 // Member hides inherited member; missing new keyword
- 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 Layer __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.dims;
- 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.TensorShape.dims).ToString() + ")\" ...");
- return dot;
- }
- public TensorShape __shape__()
- {
- return WShape;
- }
-#pragma warning disable CS0108 // Member hides inherited member; missing new keyword
- public TensorShape output_shape(TensorShape input_shape)
-#pragma warning restore CS0108 // Member hides inherited member; missing new keyword
- {
- var output_shape = input_shape.dims;
- output_shape[output_shape.Length - 1] = units;
- return new TensorShape(output_shape);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Dropout.cs b/src/TensorFlowNET.Keras/Layers/Core/Dropout.cs
deleted file mode 100644
index c75a9573..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Dropout.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Dropout
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Flatten.cs b/src/TensorFlowNET.Keras/Layers/Core/Flatten.cs
deleted file mode 100644
index f6e716f4..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Flatten.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Flatten
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Lambda.cs b/src/TensorFlowNET.Keras/Layers/Core/Lambda.cs
deleted file mode 100644
index d0511b99..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Lambda.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Lambda
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Masking.cs b/src/TensorFlowNET.Keras/Layers/Core/Masking.cs
deleted file mode 100644
index 373d77ee..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Masking.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Masking
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Permute.cs b/src/TensorFlowNET.Keras/Layers/Core/Permute.cs
deleted file mode 100644
index fa70caad..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Permute.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Permute
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/RepeatVector.cs b/src/TensorFlowNET.Keras/Layers/Core/RepeatVector.cs
deleted file mode 100644
index e1af963c..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/RepeatVector.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class RepeatVector
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/Reshape.cs b/src/TensorFlowNET.Keras/Layers/Core/Reshape.cs
deleted file mode 100644
index c0d5c00f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/Reshape.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Reshape
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout1D.cs b/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout1D.cs
deleted file mode 100644
index 3b3c59de..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class SpatialDropout1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout2D.cs b/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout2D.cs
deleted file mode 100644
index 639854f4..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class SpatialDropout2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout3D.cs b/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout3D.cs
deleted file mode 100644
index b76abc38..00000000
--- a/src/TensorFlowNET.Keras/Layers/Core/SpatialDropout3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class SpatialDropout3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/CuDNNGRU.cs b/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/CuDNNGRU.cs
deleted file mode 100644
index 5858b3ec..00000000
--- a/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/CuDNNGRU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class CuDNNGRU
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/CuDNNLSTM.cs b/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/CuDNNLSTM.cs
deleted file mode 100644
index dc5ff973..00000000
--- a/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/CuDNNLSTM.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class CuDNNLSTM
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/_CuDNNRNN.cs b/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/_CuDNNRNN.cs
deleted file mode 100644
index 93d87934..00000000
--- a/src/TensorFlowNET.Keras/Layers/CuDnnRecurrent/_CuDNNRNN.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class _CuDNNRNN
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Dense.cs b/src/TensorFlowNET.Keras/Layers/Dense.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Dense.cs
rename to src/TensorFlowNET.Keras/Layers/Dense.cs
diff --git a/src/TensorFlowNET.Keras/Layers/DenseAttention/AdditiveAttention.cs b/src/TensorFlowNET.Keras/Layers/DenseAttention/AdditiveAttention.cs
deleted file mode 100644
index d30a2e79..00000000
--- a/src/TensorFlowNET.Keras/Layers/DenseAttention/AdditiveAttention.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class AdditiveAttention
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/DenseAttention/Attention.cs b/src/TensorFlowNET.Keras/Layers/DenseAttention/Attention.cs
deleted file mode 100644
index 31287bfc..00000000
--- a/src/TensorFlowNET.Keras/Layers/DenseAttention/Attention.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Attention
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/DenseAttention/BaseDenseAttention.cs b/src/TensorFlowNET.Keras/Layers/DenseAttention/BaseDenseAttention.cs
deleted file mode 100644
index 94ec5191..00000000
--- a/src/TensorFlowNET.Keras/Layers/DenseAttention/BaseDenseAttention.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class BaseDenseAttention
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Dropout.cs b/src/TensorFlowNET.Keras/Layers/Dropout.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Dropout.cs
rename to src/TensorFlowNET.Keras/Layers/Dropout.cs
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Embedding.cs b/src/TensorFlowNET.Keras/Layers/Embedding.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Embedding.cs
rename to src/TensorFlowNET.Keras/Layers/Embedding.cs
diff --git a/src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs b/src/TensorFlowNET.Keras/Layers/InputLayer.cs
similarity index 95%
rename from src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs
rename to src/TensorFlowNET.Keras/Layers/InputLayer.cs
index f10a1a7b..b58ce777 100644
--- a/src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs
+++ b/src/TensorFlowNET.Keras/Layers/InputLayer.cs
@@ -19,6 +19,7 @@ using Tensorflow.Framework.Models;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras.Layers
{
@@ -48,7 +49,7 @@ namespace Tensorflow.Keras.Layers
if (string.IsNullOrEmpty(args.Name))
{
var prefix = "input";
- name = prefix + '_' + tf.keras.backend.get_uid(prefix);
+ name = prefix + '_' + keras.backend.get_uid(prefix);
}
if (args.DType == TF_DataType.DtInvalid)
@@ -72,7 +73,7 @@ namespace Tensorflow.Keras.Layers
args.BatchInputShape = null;
}
- args.InputTensor = tf.keras.backend.placeholder(
+ args.InputTensor = keras.backend.placeholder(
shape: BatchInputShape,
dtype: DType,
name: Name,
diff --git a/src/TensorFlowNET.Keras/Layers/Kernelized.cs b/src/TensorFlowNET.Keras/Layers/Kernelized.cs
deleted file mode 100644
index 94f45d66..00000000
--- a/src/TensorFlowNET.Keras/Layers/Kernelized.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Kernelized
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/LSTM.cs b/src/TensorFlowNET.Keras/Layers/LSTM.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/LSTM.cs
rename to src/TensorFlowNET.Keras/Layers/LSTM.cs
diff --git a/src/TensorFlowNET.Core/Keras/Layers/LSTMCell.cs b/src/TensorFlowNET.Keras/Layers/LSTMCell.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/LSTMCell.cs
rename to src/TensorFlowNET.Keras/Layers/LSTMCell.cs
diff --git a/src/TensorFlowNET.Keras/Layers/Layer.cs b/src/TensorFlowNET.Keras/Layers/Layer.cs
deleted file mode 100644
index 84a8bca2..00000000
--- a/src/TensorFlowNET.Keras/Layers/Layer.cs
+++ /dev/null
@@ -1,422 +0,0 @@
-using NumSharp;
-using System;
-using System.Collections.Generic;
-using Tensorflow;
-using Tensorflow.Keras.Constraints;
-using Tensorflow.Keras.Initializers;
-using Tensorflow.Keras.Losses;
-using Tensorflow.Keras.Metrics;
-using Tensorflow.Keras.Regularizers;
-
-namespace Keras.Layers
-{
- public abstract class Layer
- {
- public TF_DataType dtype
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public string name
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public bool stateful
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public bool trainable
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Regularizer activity_regularizer
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public dynamic input_spec
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] trainable_weights
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] non_trainable_weights
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private Tensor[] _weights
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Func[] updates
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] losses
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] metrics
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] input_mask
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] output_mask
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] input
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] output
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public TensorShape[] input_shape
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public TensorShape[] output_shape
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Tensor[] variables
- {
- get
- {
- return _weights;
- }
- }
-
- public Tensor[] trainable_variables
- {
- get
- {
- return trainable_weights;
- }
- }
-
- public Tensor[] non_trainable_variables
- {
- get
- {
- return non_trainable_weights;
- }
- }
-
- private string _compute_dtype
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Layer(bool trainable = true, string name = null, string dtype = null, bool @dynamic = false, Dictionary kwargs = null)
- {
-
- }
-
- public void build(TensorShape shape) => throw new NotImplementedException();
-
- public virtual void call(Tensor[] inputs) => throw new NotImplementedException();
-
- public void _add_trackable(dynamic trackable_object, bool trainable) => throw new NotImplementedException();
-
- public void add_weight(string name= null, TensorShape shape= null, string dtype= null, Initializer initializer = null,
- Regularizer regularizer = null, bool? trainable = null, ConstraintBase constraint = null,
- dynamic partitioner= null, bool? use_resource= null, VariableSynchronization synchronization= VariableSynchronization.Auto,
- VariableAggregation aggregation= VariableAggregation.None, Dictionary kwargs = null) => throw new NotImplementedException();
-
- public virtual Dictionary get_config() => throw new NotImplementedException();
-
- public Layer from_config(Dictionary config) => throw new NotImplementedException();
-
- public TensorShape compute_output_shape(TensorShape input_shape) => throw new NotImplementedException();
-
- public dynamic compute_output_signature(dynamic input_signature) => throw new NotImplementedException();
-
- public Tensor[] compute_mask(Tensor[] inputs, Tensor[] mask = null) => throw new NotImplementedException();
-
- public void __call__(Tensor[] inputs) => throw new NotImplementedException();
-
- public void add_loss(Loss[] losses, Tensor[] inputs = null) => throw new NotImplementedException();
-
- public void _clear_losses() => throw new NotImplementedException();
-
- public void add_metric(Tensor value, string aggregation= null, string name= null) => throw new NotImplementedException();
-
- public void add_update(Func[] updates) => throw new NotImplementedException();
-
- public void set_weights(NDArray[] weights) => throw new NotImplementedException();
-
- public NDArray[] get_weights() => throw new NotImplementedException();
-
- public Func[] get_updates_for(Tensor[] inputs) => throw new NotImplementedException();
-
- public Tensor[] get_losses_for(Tensor[] inputs) => throw new NotImplementedException();
-
- public Tensor[] get_input_mask_at(int node_index) => throw new NotImplementedException();
-
- public Tensor[] get_output_mask_at(int node_index) => throw new NotImplementedException();
-
- public TensorShape[] get_input_shape_at(int node_index) => throw new NotImplementedException();
-
- public TensorShape[] get_output_shape_at(int node_index) => throw new NotImplementedException();
-
- public Tensor[] get_input_at(int node_index) => throw new NotImplementedException();
-
- public Tensor[] get_output_at(int node_index) => throw new NotImplementedException();
-
- public int count_params() => throw new NotImplementedException();
-
- private void _set_dtype_policy(string dtype) => throw new NotImplementedException();
-
- private Tensor _maybe_cast_inputs(Tensor inputs) => throw new NotImplementedException();
-
- private void _warn_about_input_casting(string input_dtype) => throw new NotImplementedException();
-
- private string _name_scope()
- {
- return name;
- }
-
- private string _obj_reference_counts
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private dynamic _attribute_sentinel
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private dynamic _call_full_argspec
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private string[] _call_fn_args
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private string[] _call_accepts_kwargs
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private bool _should_compute_mask
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private Tensor[] _eager_losses
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- private dynamic _trackable_saved_model_saver
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private string _object_identifier
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- private string _tracking_metadata
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public Dictionary state
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- private void _init_set_name(string name, bool zero_based= true) => throw new NotImplementedException();
-
- private Metric _get_existing_metric(string name = null) => throw new NotImplementedException();
-
- private void _eager_add_metric(Metric value, string aggregation= null, string name= null) => throw new NotImplementedException();
-
- private void _symbolic_add_metric(Metric value, string aggregation = null, string name = null) => throw new NotImplementedException();
-
- private void _handle_weight_regularization(string name, IVariableV1 variable, Regularizer regularizer) => throw new NotImplementedException();
-
- private void _handle_activity_regularization(Tensor[] inputs, Tensor[] outputs) => throw new NotImplementedException();
-
- private void _set_mask_metadata(Tensor[] inputs, Tensor[] outputs, Tensor previous_mask) => throw new NotImplementedException();
-
- private Tensor[] _collect_input_masks(Tensor[] inputs, Dictionary args, Dictionary kwargs) => throw new NotImplementedException();
-
- private bool _call_arg_was_passed(string arg_name, Dictionary args, Dictionary kwargs, bool inputs_in_args= false) => throw new NotImplementedException();
-
- private T _get_call_arg_value(string arg_name, Dictionary args, Dictionary kwargs, bool inputs_in_args = false) => throw new NotImplementedException();
-
- private (Tensor[], Tensor[]) _set_connectivity_metadata_(Tensor[] inputs, Tensor[] outputs, Dictionary args, Dictionary kwargs) => throw new NotImplementedException();
-
- private void _add_inbound_node(Tensor[] input_tensors, Tensor[] output_tensors, Dictionary args = null) => throw new NotImplementedException();
-
- private AttrValue _get_node_attribute_at_index(int node_index, string attr, string attr_name) => throw new NotImplementedException();
-
- private void _maybe_build(Tensor[] inputs) => throw new NotImplementedException();
-
- private void _symbolic_call(Tensor[] inputs) => throw new NotImplementedException();
-
- private Dictionary _get_trainable_state() => throw new NotImplementedException();
-
- private void _set_trainable_state(bool trainable_state) => throw new NotImplementedException();
-
- private void _maybe_create_attribute(string name, object default_value) => throw new NotImplementedException();
-
- private void __delattr__(string name) => throw new NotImplementedException();
-
- private void __setattr__(string name, object value) => throw new NotImplementedException();
-
- private List _gather_children_attribute(string attribute) => throw new NotImplementedException();
-
- private List _gather_unique_layers() => throw new NotImplementedException();
-
- private List _gather_layers() => throw new NotImplementedException();
-
- private bool _is_layer() => throw new NotImplementedException();
-
- private void _init_call_fn_args() => throw new NotImplementedException();
-
- public dynamic _list_extra_dependencies_for_serialization(dynamic serialization_cache) => throw new NotImplementedException();
-
- public dynamic _list_functions_for_serialization(dynamic serialization_cache) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs b/src/TensorFlowNET.Keras/Layers/LayersApi.cs
similarity index 54%
rename from src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs
rename to src/TensorFlowNET.Keras/Layers/LayersApi.cs
index 1a529f44..d99f4041 100644
--- a/src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs
+++ b/src/TensorFlowNET.Keras/Layers/LayersApi.cs
@@ -2,11 +2,68 @@
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras.Layers
{
public class LayersApi
{
+ ///
+ /// Functional interface for the batch normalization layer.
+ /// http://arxiv.org/abs/1502.03167
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Tensors batch_normalization(Tensor inputs,
+ int axis = -1,
+ float momentum = 0.99f,
+ float epsilon = 0.001f,
+ bool center = true,
+ bool scale = true,
+ IInitializer beta_initializer = null,
+ IInitializer gamma_initializer = null,
+ IInitializer moving_mean_initializer = null,
+ IInitializer moving_variance_initializer = null,
+ Tensor training = null,
+ bool trainable = true,
+ string name = null,
+ bool renorm = false,
+ float renorm_momentum = 0.99f)
+ {
+ var layer = new BatchNormalization(new BatchNormalizationArgs
+ {
+ Axis = axis,
+ Momentum = momentum,
+ Epsilon = epsilon,
+ Center = center,
+ Scale = scale,
+ BetaInitializer = beta_initializer,
+ GammaInitializer = gamma_initializer,
+ MovingMeanInitializer = moving_mean_initializer,
+ MovingVarianceInitializer = moving_variance_initializer,
+ Renorm = renorm,
+ RenormMomentum = renorm_momentum,
+ Trainable = trainable,
+ Name = name
+ });
+
+ return layer.Apply(inputs);
+ }
+
///
///
///
@@ -55,19 +112,100 @@ namespace Tensorflow.Keras.Layers
BiasInitializer = bias_initializer == null ? tf.zeros_initializer : bias_initializer,
BiasRegularizer = bias_regularizer,
ActivityRegularizer = activity_regularizer,
- Activation = activation ?? tf.keras.activations.Linear
+ Activation = activation ?? keras.activations.Linear
});
+ public Tensor conv2d(Tensor inputs,
+ int filters,
+ int[] kernel_size,
+ int[] strides = null,
+ string padding = "valid",
+ string data_format = "channels_last",
+ int[] dilation_rate = null,
+ bool use_bias = true,
+ Activation activation = null,
+ IInitializer kernel_initializer = null,
+ IInitializer bias_initializer = null,
+ bool trainable = true,
+ string name = null)
+ {
+ if (strides == null)
+ strides = new int[] { 1, 1 };
+ if (dilation_rate == null)
+ dilation_rate = new int[] { 1, 1 };
+ if (bias_initializer == null)
+ bias_initializer = tf.zeros_initializer;
+
+ var layer = new Conv2D(new Conv2DArgs
+ {
+ Filters = filters,
+ KernelSize = kernel_size,
+ Strides = strides,
+ Padding = padding,
+ DataFormat = data_format,
+ DilationRate = dilation_rate,
+ Activation = activation,
+ UseBias = use_bias,
+ KernelInitializer = kernel_initializer,
+ BiasInitializer = bias_initializer,
+ Trainable = trainable,
+ Name = name
+ });
+
+ return layer.Apply(inputs);
+ }
+
public Dense Dense(int units,
Activation activation = null,
TensorShape input_shape = null)
=> new Dense(new DenseArgs
{
Units = units,
- Activation = activation ?? tf.keras.activations.Linear,
+ Activation = activation ?? keras.activations.Linear,
InputShape = input_shape
});
+ ///
+ /// Densely-connected layer class. aka fully-connected
+ /// `outputs = activation(inputs * kernel + bias)`
+ ///
+ ///
+ /// Python integer, dimensionality of the output space.
+ ///
+ /// Boolean, whether the layer uses a bias.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Tensor dense(Tensor inputs,
+ int units,
+ Activation activation = null,
+ bool use_bias = true,
+ IInitializer kernel_initializer = null,
+ IInitializer bias_initializer = null,
+ bool trainable = true,
+ string name = null,
+ bool? reuse = null)
+ {
+ if (bias_initializer == null)
+ bias_initializer = tf.zeros_initializer;
+
+ var layer = new Dense(new DenseArgs
+ {
+ Units = units,
+ Activation = activation,
+ UseBias = use_bias,
+ BiasInitializer = bias_initializer,
+ KernelInitializer = kernel_initializer,
+ Trainable = trainable,
+ Name = name
+ });
+
+ return layer.Apply(inputs);
+ }
+
public Dropout Dropout(float rate, TensorShape noise_shape = null, int? seed = null)
=> new Dropout(new DropoutArgs
{
@@ -143,6 +281,35 @@ namespace Tensorflow.Keras.Layers
Padding = padding
});
+ ///
+ /// Max pooling layer for 2D inputs (e.g. images).
+ ///
+ /// The tensor over which to pool. Must have rank 4.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Tensor max_pooling2d(Tensor inputs,
+ int[] pool_size,
+ int[] strides,
+ string padding = "valid",
+ string data_format = "channels_last",
+ string name = null)
+ {
+ var layer = new MaxPooling2D(new MaxPooling2DArgs
+ {
+ PoolSize = pool_size,
+ Strides = strides,
+ Padding = padding,
+ DataFormat = data_format,
+ Name = name
+ });
+
+ return layer.Apply(inputs);
+ }
+
public Layer LSTM(int units,
Activation activation = null,
Activation recurrent_activation = null,
@@ -163,8 +330,8 @@ namespace Tensorflow.Keras.Layers
=> new LSTM(new LSTMArgs
{
Units = units,
- Activation = activation ?? tf.keras.activations.Tanh,
- RecurrentActivation = recurrent_activation ?? tf.keras.activations.Sigmoid,
+ Activation = activation ?? keras.activations.Tanh,
+ RecurrentActivation = recurrent_activation ?? keras.activations.Sigmoid,
KernelInitializer = kernel_initializer ?? tf.glorot_uniform_initializer,
RecurrentInitializer = recurrent_initializer ?? tf.orthogonal_initializer,
BiasInitializer = bias_initializer ?? tf.zeros_initializer,
@@ -203,11 +370,11 @@ namespace Tensorflow.Keras.Layers
Activation GetActivationByName(string name)
=> name switch
{
- "linear" => tf.keras.activations.Linear,
- "relu" => tf.keras.activations.Relu,
- "sigmoid" => tf.keras.activations.Sigmoid,
- "tanh" => tf.keras.activations.Tanh,
- _ => tf.keras.activations.Linear
+ "linear" => keras.activations.Linear,
+ "relu" => keras.activations.Relu,
+ "sigmoid" => keras.activations.Sigmoid,
+ "tanh" => keras.activations.Tanh,
+ _ => keras.activations.Linear
};
}
}
diff --git a/src/TensorFlowNET.Keras/Layers/Local/Local.cs b/src/TensorFlowNET.Keras/Layers/Local/Local.cs
deleted file mode 100644
index e7920fdd..00000000
--- a/src/TensorFlowNET.Keras/Layers/Local/Local.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Local
- {
-
- }
-
-
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Local/LocallyConnected1D.cs b/src/TensorFlowNET.Keras/Layers/Local/LocallyConnected1D.cs
deleted file mode 100644
index aa5eb8c1..00000000
--- a/src/TensorFlowNET.Keras/Layers/Local/LocallyConnected1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LocallyConnected1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Local/LocallyConnected2D.cs b/src/TensorFlowNET.Keras/Layers/Local/LocallyConnected2D.cs
deleted file mode 100644
index 0b3cb2fa..00000000
--- a/src/TensorFlowNET.Keras/Layers/Local/LocallyConnected2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LocallyConnected2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs b/src/TensorFlowNET.Keras/Layers/MaxPooling2D.cs
similarity index 73%
rename from src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs
rename to src/TensorFlowNET.Keras/Layers/MaxPooling2D.cs
index c19030be..90a45cb1 100644
--- a/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs
+++ b/src/TensorFlowNET.Keras/Layers/MaxPooling2D.cs
@@ -1,5 +1,5 @@
using Tensorflow.Keras.ArgsDefinition;
-using static Tensorflow.Binding;
+using Tensorflow.Operations;
namespace Tensorflow.Keras.Layers
{
@@ -8,7 +8,7 @@ namespace Tensorflow.Keras.Layers
public MaxPooling2D(MaxPooling2DArgs args)
: base(args)
{
- args.PoolFunction = tf.nn.max_pool_fn;
+ args.PoolFunction = new MaxPoolFunction();
}
}
}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Add.cs b/src/TensorFlowNET.Keras/Layers/Merge/Add.cs
deleted file mode 100644
index c2f7805a..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Add.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Add
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Average.cs b/src/TensorFlowNET.Keras/Layers/Merge/Average.cs
deleted file mode 100644
index 89f41824..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Average.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Average
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Concatenate.cs b/src/TensorFlowNET.Keras/Layers/Merge/Concatenate.cs
deleted file mode 100644
index 842f25d4..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Concatenate.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Concatenate
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Dot.cs b/src/TensorFlowNET.Keras/Layers/Merge/Dot.cs
deleted file mode 100644
index ac339f67..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Dot.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Dot
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Maximum.cs b/src/TensorFlowNET.Keras/Layers/Merge/Maximum.cs
deleted file mode 100644
index 862d100f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Maximum.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Maximum
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Merge.cs b/src/TensorFlowNET.Keras/Layers/Merge/Merge.cs
deleted file mode 100644
index 3e0d80c2..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Merge.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Merge
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Minimum.cs b/src/TensorFlowNET.Keras/Layers/Merge/Minimum.cs
deleted file mode 100644
index 1030a4aa..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Minimum.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Minimum
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Multiply.cs b/src/TensorFlowNET.Keras/Layers/Merge/Multiply.cs
deleted file mode 100644
index 21b66d3d..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Multiply.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Multiply
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Merge/Subtract.cs b/src/TensorFlowNET.Keras/Layers/Merge/Subtract.cs
deleted file mode 100644
index d0aca561..00000000
--- a/src/TensorFlowNET.Keras/Layers/Merge/Subtract.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Subtract
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Noise/AlphaDropout.cs b/src/TensorFlowNET.Keras/Layers/Noise/AlphaDropout.cs
deleted file mode 100644
index 3fe38afc..00000000
--- a/src/TensorFlowNET.Keras/Layers/Noise/AlphaDropout.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class AlphaDropout
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Noise/GaussianDropout.cs b/src/TensorFlowNET.Keras/Layers/Noise/GaussianDropout.cs
deleted file mode 100644
index 4a272eb9..00000000
--- a/src/TensorFlowNET.Keras/Layers/Noise/GaussianDropout.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GaussianDropout
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Noise/GaussianNoise.cs b/src/TensorFlowNET.Keras/Layers/Noise/GaussianNoise.cs
deleted file mode 100644
index fa944cde..00000000
--- a/src/TensorFlowNET.Keras/Layers/Noise/GaussianNoise.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GaussianNoise
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalization.cs b/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalization.cs
deleted file mode 100644
index 4e0b70ea..00000000
--- a/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class BatchNormalization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalizationBase.cs b/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalizationBase.cs
deleted file mode 100644
index 82b7764e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalizationBase.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class BatchNormalizationBase
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalizationV2.cs b/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalizationV2.cs
deleted file mode 100644
index 32eac199..00000000
--- a/src/TensorFlowNET.Keras/Layers/Normalization/BatchNormalizationV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class BatchNormalizationV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Normalization/LayerNormalization.cs b/src/TensorFlowNET.Keras/Layers/Normalization/LayerNormalization.cs
deleted file mode 100644
index ae8b5d0e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Normalization/LayerNormalization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LayerNormalization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling1D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling1D.cs
deleted file mode 100644
index 3081a32d..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class AveragePooling1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling2D.cs
deleted file mode 100644
index 0265353e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class AveragePooling2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling3D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling3D.cs
deleted file mode 100644
index e16f204f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/AveragePooling3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class AveragePooling3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/Embedding.cs b/src/TensorFlowNET.Keras/Layers/Pooling/Embedding.cs
deleted file mode 100644
index 66937742..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/Embedding.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Embedding
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling1D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling1D.cs
deleted file mode 100644
index 4ba5b395..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalAveragePooling1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling2D.cs
deleted file mode 100644
index 44cad231..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalAveragePooling2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling3D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling3D.cs
deleted file mode 100644
index f6fc8572..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalAveragePooling3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalAveragePooling3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling1D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling1D.cs
deleted file mode 100644
index 0df982b9..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalMaxPooling1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling2D.cs
deleted file mode 100644
index 1cf9947a..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalMaxPooling2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling3D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling3D.cs
deleted file mode 100644
index 373b30fb..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalMaxPooling3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalMaxPooling3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling1D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling1D.cs
deleted file mode 100644
index fc125111..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalPooling1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling2D.cs
deleted file mode 100644
index 6cc61151..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalPooling2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling3D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling3D.cs
deleted file mode 100644
index d4b2533c..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/GlobalPooling3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GlobalPooling3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling1D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling1D.cs
deleted file mode 100644
index 6dad38f9..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class MaxPooling1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling2D.cs
deleted file mode 100644
index 886934f8..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class MaxPooling2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling3D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling3D.cs
deleted file mode 100644
index 8660959e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/MaxPooling3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class MaxPooling3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/Pooling1D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/Pooling1D.cs
deleted file mode 100644
index ddc61f6b..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/Pooling1D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Pooling1D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/Pooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/Pooling2D.cs
deleted file mode 100644
index 47c2c60a..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/Pooling2D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Pooling2D
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Pooling/Pooling3D.cs b/src/TensorFlowNET.Keras/Layers/Pooling/Pooling3D.cs
deleted file mode 100644
index 610139f7..00000000
--- a/src/TensorFlowNET.Keras/Layers/Pooling/Pooling3D.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Pooling3D
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Pooling2D.cs b/src/TensorFlowNET.Keras/Layers/Pooling2D.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Pooling2D.cs
rename to src/TensorFlowNET.Keras/Layers/Pooling2D.cs
diff --git a/src/TensorFlowNET.Keras/Layers/Processing/CategoryLookup.cs b/src/TensorFlowNET.Keras/Layers/Processing/CategoryLookup.cs
deleted file mode 100644
index 6fb1191f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Processing/CategoryLookup.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.Processing
-{
- class CategoryLookup
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Processing/ImagePreprocessing.cs b/src/TensorFlowNET.Keras/Layers/Processing/ImagePreprocessing.cs
deleted file mode 100644
index debcfe45..00000000
--- a/src/TensorFlowNET.Keras/Layers/Processing/ImagePreprocessing.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.Processing
-{
- class ImagePreprocessing
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Processing/Normalization.cs b/src/TensorFlowNET.Keras/Layers/Processing/Normalization.cs
deleted file mode 100644
index 07bf2dd6..00000000
--- a/src/TensorFlowNET.Keras/Layers/Processing/Normalization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.Processing
-{
- class Normalization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Processing/NormalizationV1.cs b/src/TensorFlowNET.Keras/Layers/Processing/NormalizationV1.cs
deleted file mode 100644
index 0c54ecc9..00000000
--- a/src/TensorFlowNET.Keras/Layers/Processing/NormalizationV1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.Processing
-{
- class NormalizationV1
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Processing/TextVectorization.cs b/src/TensorFlowNET.Keras/Layers/Processing/TextVectorization.cs
deleted file mode 100644
index 21b5f334..00000000
--- a/src/TensorFlowNET.Keras/Layers/Processing/TextVectorization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.Processing
-{
- class TextVectorization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Processing/TextVectorizationV1.cs b/src/TensorFlowNET.Keras/Layers/Processing/TextVectorizationV1.cs
deleted file mode 100644
index 07fac27c..00000000
--- a/src/TensorFlowNET.Keras/Layers/Processing/TextVectorizationV1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers.Processing
-{
- class TextVectorizationV1
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/RNN.cs b/src/TensorFlowNET.Keras/Layers/RNN.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/RNN.cs
rename to src/TensorFlowNET.Keras/Layers/RNN.cs
diff --git a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/DeviceWrapper.cs b/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/DeviceWrapper.cs
deleted file mode 100644
index 2754ba2d..00000000
--- a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/DeviceWrapper.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class DeviceWrapper
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/DropoutWrapper.cs b/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/DropoutWrapper.cs
deleted file mode 100644
index 10f310b1..00000000
--- a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/DropoutWrapper.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class DropoutWrapper
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/ResidualWrapper.cs b/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/ResidualWrapper.cs
deleted file mode 100644
index 71d31d17..00000000
--- a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/ResidualWrapper.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class ResidualWrapper
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/_RNNCellWrapperV2.cs b/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/_RNNCellWrapperV2.cs
deleted file mode 100644
index db920f3b..00000000
--- a/src/TensorFlowNET.Keras/Layers/RNNCellWrapper/_RNNCellWrapperV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class _RNNCellWrapperV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/AbstractRNNCell.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/AbstractRNNCell.cs
deleted file mode 100644
index 87c2c1b1..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/AbstractRNNCell.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class AbstractRNNCell
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/DropoutRNNCellMixin.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/DropoutRNNCellMixin.cs
deleted file mode 100644
index 7a666b95..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/DropoutRNNCellMixin.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class DropoutRNNCellMixin
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/GRU.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/GRU.cs
deleted file mode 100644
index 5fe897da..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/GRU.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GRU
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/GRUCell.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/GRUCell.cs
deleted file mode 100644
index 562b904e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/GRUCell.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GRUCell
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/GRUCellv2.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/GRUCellv2.cs
deleted file mode 100644
index 47166e48..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/GRUCellv2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GRUCellv2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/GRUv2.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/GRUv2.cs
deleted file mode 100644
index 1e218fd7..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/GRUv2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class GRUv2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTM.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/LSTM.cs
deleted file mode 100644
index 6fa6814f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTM.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LSTM
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMCell.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMCell.cs
deleted file mode 100644
index e173281f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMCell.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LSTMCell
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMCellv2.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMCellv2.cs
deleted file mode 100644
index 241ed8d1..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMCellv2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LSTMCellv2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMv2.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMv2.cs
deleted file mode 100644
index 48b4abd7..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/LSTMv2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class LSTMv2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/PeepholeLSTMCell.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/PeepholeLSTMCell.cs
deleted file mode 100644
index b38d1d3c..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/PeepholeLSTMCell.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class PeepholeLSTMCell
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/RNN.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/RNN.cs
deleted file mode 100644
index b5ebc14d..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/RNN.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class RNN
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/SimpleRNN.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/SimpleRNN.cs
deleted file mode 100644
index 431049db..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/SimpleRNN.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class SimpleRNN
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/SimpleRNNCell.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/SimpleRNNCell.cs
deleted file mode 100644
index 0b7fe9e3..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/SimpleRNNCell.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class SimpleRNNCell
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Recurrent/StackedRNNCells.cs b/src/TensorFlowNET.Keras/Layers/Recurrent/StackedRNNCells.cs
deleted file mode 100644
index e609c3f4..00000000
--- a/src/TensorFlowNET.Keras/Layers/Recurrent/StackedRNNCells.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class StackedRNNCells
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/Rescaling.cs b/src/TensorFlowNET.Keras/Layers/Rescaling.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Layers/Rescaling.cs
rename to src/TensorFlowNET.Keras/Layers/Rescaling.cs
diff --git a/src/TensorFlowNET.Keras/Layers/Wrapper/Bidirectional.cs b/src/TensorFlowNET.Keras/Layers/Wrapper/Bidirectional.cs
deleted file mode 100644
index d60f8f6f..00000000
--- a/src/TensorFlowNET.Keras/Layers/Wrapper/Bidirectional.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Bidirectional
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Wrapper/Serialization.cs b/src/TensorFlowNET.Keras/Layers/Wrapper/Serialization.cs
deleted file mode 100644
index 8bae368e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Wrapper/Serialization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Serialization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Wrapper/TimeDistributed.cs b/src/TensorFlowNET.Keras/Layers/Wrapper/TimeDistributed.cs
deleted file mode 100644
index 07ff1f6e..00000000
--- a/src/TensorFlowNET.Keras/Layers/Wrapper/TimeDistributed.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class TimeDistributed
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Layers/Wrapper/Wrapper.cs b/src/TensorFlowNET.Keras/Layers/Wrapper/Wrapper.cs
deleted file mode 100644
index 9b330b33..00000000
--- a/src/TensorFlowNET.Keras/Layers/Wrapper/Wrapper.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Layers
-{
- class Wrapper
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs b/src/TensorFlowNET.Keras/Layers/ZeroPadding2D.cs
similarity index 91%
rename from src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs
rename to src/TensorFlowNET.Keras/Layers/ZeroPadding2D.cs
index e0fb8ec1..6e479c70 100644
--- a/src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs
+++ b/src/TensorFlowNET.Keras/Layers/ZeroPadding2D.cs
@@ -2,7 +2,7 @@
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
using Tensorflow.Keras.Utils;
-using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras.Layers
{
@@ -28,7 +28,7 @@ namespace Tensorflow.Keras.Layers
protected override Tensors Call(Tensors inputs, Tensor state = null, bool is_training = false)
{
- return tf.keras.backend.spatial_2d_padding(inputs,
+ return keras.backend.spatial_2d_padding(inputs,
padding: padding,
data_format: data_format);
}
diff --git a/src/TensorFlowNET.Keras/Losses/BinaryCrossentropy.cs b/src/TensorFlowNET.Keras/Losses/BinaryCrossentropy.cs
deleted file mode 100644
index 20eb319e..00000000
--- a/src/TensorFlowNET.Keras/Losses/BinaryCrossentropy.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class BinaryCrossentropy
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/CategoricalCrossentropy.cs b/src/TensorFlowNET.Keras/Losses/CategoricalCrossentropy.cs
deleted file mode 100644
index 2afbb862..00000000
--- a/src/TensorFlowNET.Keras/Losses/CategoricalCrossentropy.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class CategoricalCrossentropy
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/CategoricalHinge.cs b/src/TensorFlowNET.Keras/Losses/CategoricalHinge.cs
deleted file mode 100644
index e93934a2..00000000
--- a/src/TensorFlowNET.Keras/Losses/CategoricalHinge.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class CategoricalHinge
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/CosineSimilarity.cs b/src/TensorFlowNET.Keras/Losses/CosineSimilarity.cs
deleted file mode 100644
index 6411d34e..00000000
--- a/src/TensorFlowNET.Keras/Losses/CosineSimilarity.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class CosineSimilarity
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/Hinge.cs b/src/TensorFlowNET.Keras/Losses/Hinge.cs
deleted file mode 100644
index 88f90ef0..00000000
--- a/src/TensorFlowNET.Keras/Losses/Hinge.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class Hinge
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/Huber.cs b/src/TensorFlowNET.Keras/Losses/Huber.cs
deleted file mode 100644
index 54fa95cd..00000000
--- a/src/TensorFlowNET.Keras/Losses/Huber.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class Huber
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Losses/ILossFunc.cs b/src/TensorFlowNET.Keras/Losses/ILossFunc.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Losses/ILossFunc.cs
rename to src/TensorFlowNET.Keras/Losses/ILossFunc.cs
diff --git a/src/TensorFlowNET.Keras/Losses/KLDivergence.cs b/src/TensorFlowNET.Keras/Losses/KLDivergence.cs
deleted file mode 100644
index 7cda8b66..00000000
--- a/src/TensorFlowNET.Keras/Losses/KLDivergence.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class KLDivergence
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/LogCosh.cs b/src/TensorFlowNET.Keras/Losses/LogCosh.cs
deleted file mode 100644
index 0aa52e16..00000000
--- a/src/TensorFlowNET.Keras/Losses/LogCosh.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class LogCosh
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/Loss.cs b/src/TensorFlowNET.Keras/Losses/Loss.cs
index 8acee5ba..07d629b6 100644
--- a/src/TensorFlowNET.Keras/Losses/Loss.cs
+++ b/src/TensorFlowNET.Keras/Losses/Loss.cs
@@ -1,41 +1,41 @@
using System;
-using System.Collections.Generic;
-using System.Text;
+using Tensorflow.Keras.Utils;
namespace Tensorflow.Keras.Losses
{
+ ///
+ /// Loss base class.
+ ///
public abstract class Loss
{
- public static Tensor mean_squared_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor mean_absolute_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor mean_absolute_percentage_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor mean_squared_logarithmic_error(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor _maybe_convert_labels(Tensor y_true) => throw new NotImplementedException();
-
- public static Tensor squared_hinge(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor hinge(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor categorical_hinge(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor huber_loss(Tensor y_true, Tensor y_pred, float delta = 1) => throw new NotImplementedException();
-
- public static Tensor logcosh(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor categorical_crossentropy(Tensor y_true, Tensor y_pred, bool from_logits = false, float label_smoothing = 0) => throw new NotImplementedException();
-
- public static Tensor sparse_categorical_crossentropy(Tensor y_true, Tensor y_pred, bool from_logits = false, float axis = -1) => throw new NotImplementedException();
-
- public static Tensor binary_crossentropy(Tensor y_true, Tensor y_pred, bool from_logits = false, float label_smoothing = 0) => throw new NotImplementedException();
-
- public static Tensor kullback_leibler_divergence(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor poisson(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor cosine_similarity(Tensor y_true, Tensor y_pred, int axis = -1) => throw new NotImplementedException();
+ protected string reduction;
+ protected string name;
+ bool _allow_sum_over_batch_size;
+ string _name_scope;
+
+ public string Reduction => reduction;
+
+ public Loss(string reduction = ReductionV2.AUTO, string name = null)
+ {
+ this.reduction = reduction;
+ this.name = name;
+ _allow_sum_over_batch_size = false;
+ }
+
+ public virtual Tensor Apply(Tensor y_true, Tensor y_pred, bool from_logits = false, int axis = -1)
+ {
+ throw new NotImplementedException("");
+ }
+
+ public Tensor Call(Tensor y_true, Tensor y_pred)
+ {
+ var losses = Apply(y_true, y_pred);
+ return losses_utils.compute_weighted_loss(losses, reduction: ReductionV2.SUM_OVER_BATCH_SIZE);
+ }
+
+ void _set_name_scope()
+ {
+ _name_scope = name;
+ }
}
}
diff --git a/src/TensorFlowNET.Keras/Losses/LossFunctionWrapper.cs b/src/TensorFlowNET.Keras/Losses/LossFunctionWrapper.cs
index 666760df..af352aa9 100644
--- a/src/TensorFlowNET.Keras/Losses/LossFunctionWrapper.cs
+++ b/src/TensorFlowNET.Keras/Losses/LossFunctionWrapper.cs
@@ -1,10 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
+namespace Tensorflow.Keras.Losses
{
- class LossFunctionWrapper
+ public class LossFunctionWrapper : Loss
{
+ public LossFunctionWrapper(string reduction = ReductionV2.AUTO,
+ string name = null)
+ : base(reduction: reduction,
+ name: name)
+ {
+ }
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Losses/LossesApi.cs b/src/TensorFlowNET.Keras/Losses/LossesApi.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Losses/LossesApi.cs
rename to src/TensorFlowNET.Keras/Losses/LossesApi.cs
diff --git a/src/TensorFlowNET.Keras/Losses/MeanAbsoluteError.cs b/src/TensorFlowNET.Keras/Losses/MeanAbsoluteError.cs
deleted file mode 100644
index dbdbd790..00000000
--- a/src/TensorFlowNET.Keras/Losses/MeanAbsoluteError.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class MeanAbsoluteError
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/MeanAbsolutePercentageError.cs b/src/TensorFlowNET.Keras/Losses/MeanAbsolutePercentageError.cs
deleted file mode 100644
index cff3e683..00000000
--- a/src/TensorFlowNET.Keras/Losses/MeanAbsolutePercentageError.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class MeanAbsolutePercentageError
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/MeanSquaredError.cs b/src/TensorFlowNET.Keras/Losses/MeanSquaredError.cs
deleted file mode 100644
index a76ae4cc..00000000
--- a/src/TensorFlowNET.Keras/Losses/MeanSquaredError.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class MeanSquaredError
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/MeanSquaredLogarithmicError.cs b/src/TensorFlowNET.Keras/Losses/MeanSquaredLogarithmicError.cs
deleted file mode 100644
index d3b6c36c..00000000
--- a/src/TensorFlowNET.Keras/Losses/MeanSquaredLogarithmicError.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class MeanSquaredLogarithmicError
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Losses/Poisson.cs b/src/TensorFlowNET.Keras/Losses/Poisson.cs
deleted file mode 100644
index 254f9949..00000000
--- a/src/TensorFlowNET.Keras/Losses/Poisson.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class Poisson
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Losses/ReductionV2.cs b/src/TensorFlowNET.Keras/Losses/ReductionV2.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Losses/ReductionV2.cs
rename to src/TensorFlowNET.Keras/Losses/ReductionV2.cs
diff --git a/src/TensorFlowNET.Keras/Losses/SparseCategoricalCrossentropy.cs b/src/TensorFlowNET.Keras/Losses/SparseCategoricalCrossentropy.cs
index 00964a89..fe14e887 100644
--- a/src/TensorFlowNET.Keras/Losses/SparseCategoricalCrossentropy.cs
+++ b/src/TensorFlowNET.Keras/Losses/SparseCategoricalCrossentropy.cs
@@ -1,10 +1,33 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using static Tensorflow.Binding;
namespace Tensorflow.Keras.Losses
{
- class SparseCategoricalCrossentropy
+ public class SparseCategoricalCrossentropy : LossFunctionWrapper, ILossFunc
{
+ public SparseCategoricalCrossentropy(bool from_logits = false,
+ string reduction = ReductionV2.AUTO,
+ string name = "sparse_categorical_crossentropy") :
+ base(reduction: reduction,
+ name: name)
+ {
+
+ }
+
+ public override Tensor Apply(Tensor target, Tensor output, bool from_logits = false, int axis = -1)
+ {
+ target = tf.cast(target, dtype: TF_DataType.TF_INT64);
+
+ // Try to adjust the shape so that rank of labels = rank of logits - 1.
+ var output_shape = array_ops.shape_v2(output);
+ var output_rank = output.TensorShape.ndim;
+ var target_rank = target.TensorShape.ndim;
+ var update_shape = target_rank != output_rank - 1;
+ if (update_shape)
+ {
+ target = array_ops.reshape(target, new int[] { -1 });
+ output = array_ops.reshape(output, new int[] { -1, output_shape[-1].numpy() });
+ }
+ return tf.nn.sparse_softmax_cross_entropy_with_logits(target, output);
+ }
}
}
diff --git a/src/TensorFlowNET.Keras/Losses/SquaredHinge.cs b/src/TensorFlowNET.Keras/Losses/SquaredHinge.cs
deleted file mode 100644
index 60d83ef0..00000000
--- a/src/TensorFlowNET.Keras/Losses/SquaredHinge.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Losses
-{
- class SquaredHinge
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/AUC.cs b/src/TensorFlowNET.Keras/Metrics/AUC.cs
deleted file mode 100644
index c34f61c8..00000000
--- a/src/TensorFlowNET.Keras/Metrics/AUC.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class AUC : Metric
- {
- public AUC(int num_thresholds= 200, string curve= "ROC", string summation_method= "interpolation",
- string name= null, string dtype= null, float thresholds= 0.5f,
- bool multi_label= false, Tensor label_weights= null) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- private void _build(TensorShape shape) => throw new NotImplementedException();
-
- public Tensor interpolate_pr_auc() => throw new NotImplementedException();
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Accuracy.cs b/src/TensorFlowNET.Keras/Metrics/Accuracy.cs
deleted file mode 100644
index cb58ae91..00000000
--- a/src/TensorFlowNET.Keras/Metrics/Accuracy.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class Accuracy : MeanMetricWrapper
- {
- public Accuracy(string name = "accuracy", string dtype = null)
- : base(Metric.accuracy, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/BinaryAccuracy.cs b/src/TensorFlowNET.Keras/Metrics/BinaryAccuracy.cs
deleted file mode 100644
index 682ed236..00000000
--- a/src/TensorFlowNET.Keras/Metrics/BinaryAccuracy.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class BinaryAccuracy : MeanMetricWrapper
- {
- public BinaryAccuracy(string name = "binary_accuracy", string dtype = null, float threshold = 0.5f)
- : base(Fn, name, dtype)
- {
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Metric.binary_accuracy(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/BinaryCrossentropy.cs b/src/TensorFlowNET.Keras/Metrics/BinaryCrossentropy.cs
deleted file mode 100644
index 14ef73b9..00000000
--- a/src/TensorFlowNET.Keras/Metrics/BinaryCrossentropy.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class BinaryCrossentropy : MeanMetricWrapper
- {
- public BinaryCrossentropy(string name = "binary_crossentropy", string dtype = null, bool from_logits = false, float label_smoothing = 0)
- : base(Fn, name, dtype)
- {
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Losses.Loss.binary_crossentropy(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/CategoricalAccuracy.cs b/src/TensorFlowNET.Keras/Metrics/CategoricalAccuracy.cs
deleted file mode 100644
index 64b31f64..00000000
--- a/src/TensorFlowNET.Keras/Metrics/CategoricalAccuracy.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class CategoricalAccuracy : MeanMetricWrapper
- {
- public CategoricalAccuracy(string name = "categorical_accuracy", string dtype = null)
- : base(Metric.categorical_accuracy, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/CategoricalCrossentropy.cs b/src/TensorFlowNET.Keras/Metrics/CategoricalCrossentropy.cs
deleted file mode 100644
index c83bb5d5..00000000
--- a/src/TensorFlowNET.Keras/Metrics/CategoricalCrossentropy.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class CategoricalCrossentropy : MeanMetricWrapper
- {
- public CategoricalCrossentropy(string name = "categorical_crossentropy", string dtype = null, bool from_logits = false, float label_smoothing = 0)
- : base(Fn, name, dtype)
- {
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Losses.Loss.categorical_crossentropy(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/CategoricalHinge.cs b/src/TensorFlowNET.Keras/Metrics/CategoricalHinge.cs
deleted file mode 100644
index 1f82d725..00000000
--- a/src/TensorFlowNET.Keras/Metrics/CategoricalHinge.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class CategoricalHinge : MeanMetricWrapper
- {
- public CategoricalHinge(string name = "categorical_hinge", string dtype = null)
- : base(Losses.Loss.categorical_hinge, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/CosineSimilarity.cs b/src/TensorFlowNET.Keras/Metrics/CosineSimilarity.cs
deleted file mode 100644
index abce27c8..00000000
--- a/src/TensorFlowNET.Keras/Metrics/CosineSimilarity.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class CosineSimilarity : MeanMetricWrapper
- {
- public CosineSimilarity(string name = "cosine_similarity", string dtype = null, int axis = -1)
- : base(Fn, name, dtype)
- {
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Metric.cosine_proximity(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/FalseNegatives.cs b/src/TensorFlowNET.Keras/Metrics/FalseNegatives.cs
deleted file mode 100644
index fb27484e..00000000
--- a/src/TensorFlowNET.Keras/Metrics/FalseNegatives.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class FalseNegatives : _ConfusionMatrixConditionCount
- {
- public FalseNegatives(float thresholds = 0.5F, string name = null, string dtype = null)
- : base(Utils.MetricsUtils.ConfusionMatrix.FALSE_NEGATIVES, thresholds, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/FalsePositives.cs b/src/TensorFlowNET.Keras/Metrics/FalsePositives.cs
deleted file mode 100644
index 1b97e556..00000000
--- a/src/TensorFlowNET.Keras/Metrics/FalsePositives.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class FalsePositives : _ConfusionMatrixConditionCount
- {
- public FalsePositives(float thresholds = 0.5F, string name = null, string dtype = null)
- : base(Utils.MetricsUtils.ConfusionMatrix.FALSE_POSITIVES, thresholds, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Hinge.cs b/src/TensorFlowNET.Keras/Metrics/Hinge.cs
deleted file mode 100644
index 21ebe067..00000000
--- a/src/TensorFlowNET.Keras/Metrics/Hinge.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class Hinge : MeanMetricWrapper
- {
- public Hinge(string name = "hinge", string dtype = null)
- : base(Losses.Loss.hinge, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/KLDivergence.cs b/src/TensorFlowNET.Keras/Metrics/KLDivergence.cs
deleted file mode 100644
index 814b14ce..00000000
--- a/src/TensorFlowNET.Keras/Metrics/KLDivergence.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class KLDivergence : MeanMetricWrapper
- {
- public KLDivergence(string name = "kullback_leibler_divergence", string dtype = null)
- : base(Losses.Loss.logcosh, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/LogCoshError.cs b/src/TensorFlowNET.Keras/Metrics/LogCoshError.cs
deleted file mode 100644
index 595f4aa7..00000000
--- a/src/TensorFlowNET.Keras/Metrics/LogCoshError.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class LogCoshError : MeanMetricWrapper
- {
- public LogCoshError(string name = "logcosh", string dtype = null)
- : base(Losses.Loss.logcosh, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Mean.cs b/src/TensorFlowNET.Keras/Metrics/Mean.cs
index 64b8b5db..8a55690b 100644
--- a/src/TensorFlowNET.Keras/Metrics/Mean.cs
+++ b/src/TensorFlowNET.Keras/Metrics/Mean.cs
@@ -1,15 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
+namespace Tensorflow.Keras.Metrics
{
+ ///
+ /// Computes the (weighted) mean of the given values.
+ ///
public class Mean : Reduce
{
- public Mean(string name, string dtype = null)
- : base(Reduction.MEAN, name, dtype)
+ public Mean(string name = "mean", TF_DataType dtype = TF_DataType.TF_FLOAT)
+ : base(Reduction.WEIGHTED_MEAN, name, dtype: dtype)
{
- }
+ }
}
}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanAbsoluteError.cs b/src/TensorFlowNET.Keras/Metrics/MeanAbsoluteError.cs
deleted file mode 100644
index c326a6dd..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanAbsoluteError.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanAbsoluteError : MeanMetricWrapper
- {
- public MeanAbsoluteError(string name = "mean_absolute_error", string dtype = null)
- : base(Losses.Loss.mean_absolute_error, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanAbsolutePercentageError.cs b/src/TensorFlowNET.Keras/Metrics/MeanAbsolutePercentageError.cs
deleted file mode 100644
index 0c51a5be..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanAbsolutePercentageError.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanAbsolutePercentageError : MeanMetricWrapper
- {
- public MeanAbsolutePercentageError(string name = "mean_absolute_percentage_error", string dtype = null)
- : base(Losses.Loss.mean_absolute_percentage_error, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanIoU.cs b/src/TensorFlowNET.Keras/Metrics/MeanIoU.cs
deleted file mode 100644
index d8975218..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanIoU.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanIoU : Metric
- {
- public MeanIoU(int num_classes, string name, string dtype) : base(name, dtype)
- {
- }
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanMetricWrapper.cs b/src/TensorFlowNET.Keras/Metrics/MeanMetricWrapper.cs
index ccc7922b..3bdfe6d3 100644
--- a/src/TensorFlowNET.Keras/Metrics/MeanMetricWrapper.cs
+++ b/src/TensorFlowNET.Keras/Metrics/MeanMetricWrapper.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Text;
@@ -7,19 +6,22 @@ namespace Tensorflow.Keras.Metrics
{
public class MeanMetricWrapper : Mean
{
- public MeanMetricWrapper(Func fn, string name, string dtype = null) : base(name, dtype)
+ string name;
+ Func _fn = null;
+
+ public MeanMetricWrapper(Func fn, string name, TF_DataType dtype = TF_DataType.TF_FLOAT)
+ : base(name: name, dtype: dtype)
{
- throw new NotImplementedException();
+ _fn = fn;
}
- public override Tensor result()
+ public override Tensor update_state(Tensor y_true, Tensor y_pred, Tensor sample_weight = null)
{
- throw new NotImplementedException();
- }
+ y_true = math_ops.cast(y_true, _dtype);
+ y_pred = math_ops.cast(y_pred, _dtype);
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
+ var matches = _fn(y_true, y_pred);
+ return update_state(matches, sample_weight: sample_weight);
}
}
}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanRelativeError.cs b/src/TensorFlowNET.Keras/Metrics/MeanRelativeError.cs
deleted file mode 100644
index 9ae76a6a..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanRelativeError.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanRelativeError : Metric
- {
- public MeanRelativeError(Tensor normalizer, string name, string dtype) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanSquaredError.cs b/src/TensorFlowNET.Keras/Metrics/MeanSquaredError.cs
deleted file mode 100644
index e23b0f41..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanSquaredError.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanSquaredError : MeanMetricWrapper
- {
- public MeanSquaredError(string name = "mean_squared_error", string dtype = null)
- : base(Losses.Loss.mean_squared_error, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanSquaredLogarithmicError.cs b/src/TensorFlowNET.Keras/Metrics/MeanSquaredLogarithmicError.cs
deleted file mode 100644
index 9f56b9d8..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanSquaredLogarithmicError.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanSquaredLogarithmicError : MeanMetricWrapper
- {
- public MeanSquaredLogarithmicError(string name = "mean_squared_logarithmic_error", string dtype = null)
- : base(Losses.Loss.mean_squared_logarithmic_error, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/MeanTensor.cs b/src/TensorFlowNET.Keras/Metrics/MeanTensor.cs
deleted file mode 100644
index 114329b1..00000000
--- a/src/TensorFlowNET.Keras/Metrics/MeanTensor.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class MeanTensor : Metric
- {
- public int total
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public int count
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public MeanTensor(int num_classes, string name = "mean_tensor", string dtype = null) : base(name, dtype)
- {
- }
-
-
- private void _build(TensorShape shape) => throw new NotImplementedException();
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Metric.cs b/src/TensorFlowNET.Keras/Metrics/Metric.cs
index 10a3676b..9cbaaeb7 100644
--- a/src/TensorFlowNET.Keras/Metrics/Metric.cs
+++ b/src/TensorFlowNET.Keras/Metrics/Metric.cs
@@ -1,63 +1,62 @@
using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
+using Tensorflow.Keras.ArgsDefinition;
+using Tensorflow.Keras.Engine;
+using static Tensorflow.Binding;
namespace Tensorflow.Keras.Metrics
{
- public abstract class Metric : Layers.Layer
+ ///
+ /// Encapsulates metric logic and state.
+ ///
+ public class Metric : Layer
{
- public string dtype
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ protected IVariableV1 total;
+ protected IVariableV1 count;
+ protected string _reduction;
+ protected TF_DataType _dtype;
- public Metric(string name, string dtype)
+ public Metric(string name = null, TF_DataType dtype = TF_DataType.DtInvalid)
+ : base(new LayerArgs
+ {
+ Name = name,
+ DType = dtype
+ })
{
- throw new NotImplementedException();
+ stateful = true;
+ built = true;
}
- public void __new__ (Metric cls, Args args, KwArgs kwargs) => throw new NotImplementedException();
-
- public Tensor __call__(Metric cls, Args args, KwArgs kwargs) => throw new NotImplementedException();
-
- public virtual Hashtable get_config() => throw new NotImplementedException();
-
- public virtual void reset_states() => throw new NotImplementedException();
-
- public abstract void update_state(Args args, KwArgs kwargs);
-
- public abstract Tensor result();
-
- public void add_weight(string name, TensorShape shape= null, VariableAggregation aggregation= VariableAggregation.Sum,
- VariableSynchronization synchronization = VariableSynchronization.OnRead, Initializers.Initializer initializer= null,
- string dtype= null) => throw new NotImplementedException();
-
- public static Tensor accuracy(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor binary_accuracy(Tensor y_true, Tensor y_pred, float threshold = 0.5f) => throw new NotImplementedException();
-
- public static Tensor categorical_accuracy(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor sparse_categorical_accuracy(Tensor y_true, Tensor y_pred) => throw new NotImplementedException();
-
- public static Tensor top_k_categorical_accuracy(Tensor y_true, Tensor y_pred, int k = 5) => throw new NotImplementedException();
-
- public static Tensor sparse_top_k_categorical_accuracy(Tensor y_true, Tensor y_pred, int k = 5) => throw new NotImplementedException();
-
- public static Tensor cosine_proximity(Tensor y_true, Tensor y_pred, int axis = -1) => throw new NotImplementedException();
-
- public static Metric clone_metric(Metric metric) => throw new NotImplementedException();
+ protected override IVariableV1 add_weight(string name,
+ TensorShape shape = null,
+ TF_DataType dtype = TF_DataType.TF_FLOAT,
+ IInitializer initializer = null,
+ IRegularizer regularizer = null,
+ VariableSynchronization synchronization = VariableSynchronization.OnRead,
+ VariableAggregation aggregation = VariableAggregation.Sum,
+ bool trainable = true,
+ Func getter = null)
+ {
+ if (shape == null)
+ shape = new TensorShape(new int[0]);
- public static Metric[] clone_metrics(Metric[] metric) => throw new NotImplementedException();
+ return tf_with(ops.init_scope(), delegate
+ {
+ return base.add_weight(name, shape,
+ dtype: dtype,
+ trainable: false,
+ initializer: initializer,
+ synchronization: synchronization,
+ aggregation: aggregation);
+ });
+ }
- public static string serialize(Metric metric) => throw new NotImplementedException();
+ public virtual Tensor update_state(Tensor y_true, Tensor y_pred, Tensor sample_weight = null)
+ => throw new NotImplementedException("");
- public static Metric deserialize(string config, object custom_objects = null) => throw new NotImplementedException();
+ public virtual Tensor result()
+ => throw new NotImplementedException("");
- public static Metric get(object identifier) => throw new NotImplementedException();
+ public override string ToString()
+ => $"{name} {(float)total.numpy()}/{(float)count.numpy()}";
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Metrics/MetricsApi.cs b/src/TensorFlowNET.Keras/Metrics/MetricsApi.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Metrics/MetricsApi.cs
rename to src/TensorFlowNET.Keras/Metrics/MetricsApi.cs
diff --git a/src/TensorFlowNET.Keras/Metrics/Poisson.cs b/src/TensorFlowNET.Keras/Metrics/Poisson.cs
deleted file mode 100644
index 7cdf5bd9..00000000
--- a/src/TensorFlowNET.Keras/Metrics/Poisson.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class Poisson : MeanMetricWrapper
- {
- public Poisson(string name = "logcosh", string dtype = null)
- : base(Losses.Loss.logcosh, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Precision.cs b/src/TensorFlowNET.Keras/Metrics/Precision.cs
deleted file mode 100644
index 3d5c7248..00000000
--- a/src/TensorFlowNET.Keras/Metrics/Precision.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class Precision : Metric
- {
- public Precision(float? thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public Precision(float[] thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
-
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/PrecisionAtRecall.cs b/src/TensorFlowNET.Keras/Metrics/PrecisionAtRecall.cs
deleted file mode 100644
index 05558232..00000000
--- a/src/TensorFlowNET.Keras/Metrics/PrecisionAtRecall.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class PrecisionAtRecall : SensitivitySpecificityBase
- {
- public PrecisionAtRecall(float recall, int num_thresholds = 200, string name = null, string dtype = null) : base(recall, num_thresholds, name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Recall.cs b/src/TensorFlowNET.Keras/Metrics/Recall.cs
deleted file mode 100644
index 804d4461..00000000
--- a/src/TensorFlowNET.Keras/Metrics/Recall.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class Recall : Metric
- {
- public Recall(float? thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public Recall(float[] thresholds = null, int? top_k = null, int? class_id = null, string name = null, string dtype = null) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
-
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Reduce.cs b/src/TensorFlowNET.Keras/Metrics/Reduce.cs
index 143f441e..f7cdb8f5 100644
--- a/src/TensorFlowNET.Keras/Metrics/Reduce.cs
+++ b/src/TensorFlowNET.Keras/Metrics/Reduce.cs
@@ -1,25 +1,74 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using Tensorflow.Keras.Losses;
+using Tensorflow.Keras.Utils;
+using static Tensorflow.Binding;
namespace Tensorflow.Keras.Metrics
{
+ ///
+ /// Encapsulates metrics that perform a reduce operation on the values.
+ ///
public class Reduce : Metric
{
- public Reduce(string reduction, string name, string dtype= null)
- : base(name, dtype)
+ public Reduce(string reduction, string name, TF_DataType dtype = TF_DataType.DtInvalid)
+ : base(name: name, dtype: dtype)
{
- throw new NotImplementedException();
+ _reduction = reduction;
+ _dtype = dtype;
+ total = add_weight("total", initializer: tf.zeros_initializer);
+
+ if (reduction == Reduction.WEIGHTED_MEAN ||
+ reduction == Reduction.SUM_OVER_BATCH_SIZE)
+ {
+ count = add_weight("count", initializer: tf.zeros_initializer);
+ }
}
- public override Tensor result()
+ public Tensor update_state(Tensor values, Tensor sample_weight = null)
{
- throw new NotImplementedException();
+ if (sample_weight != null)
+ {
+ (values, sample_weight) = losses_utils.squeeze_or_expand_dimensions(
+ values, sample_weight: sample_weight);
+
+ sample_weight = math_ops.cast(sample_weight, dtype: values.dtype);
+ values = math_ops.multiply(values, sample_weight);
+ }
+
+ Tensor update_total_op = null;
+ var value_sum = math_ops.reduce_sum(values);
+ tf_with(ops.control_dependencies(new[] { value_sum }), ctl =>
+ {
+ update_total_op = total.assign_add(value_sum);
+ });
+
+ // Exit early if the reduction doesn't have a denominator.
+ if (_reduction == Reduction.SUM)
+ return update_total_op;
+
+ // Update `count` for reductions that require a denominator.
+ Tensor num_values = null;
+ if (_reduction == Reduction.SUM_OVER_BATCH_SIZE)
+ num_values = math_ops.cast(array_ops.size(values), _dtype);
+ else if (_reduction == ReductionV2.WEIGHTED_MEAN)
+ {
+ if (sample_weight == null)
+ num_values = math_ops.cast(array_ops.size(values), _dtype);
+ else
+ num_values = math_ops.reduce_sum(sample_weight);
+ }
+
+ return tf_with(ops.control_dependencies(new[] { update_total_op }), ctl
+ => count.assign_add(num_values));
}
- public override void update_state(Args args, KwArgs kwargs)
+ public override Tensor result()
{
- throw new NotImplementedException();
+ if (_reduction == Reduction.SUM)
+ return array_ops.identity(total.AsTensor());
+ else if (_reduction == Reduction.WEIGHTED_MEAN || _reduction == Reduction.SUM_OVER_BATCH_SIZE)
+ return math_ops.div_no_nan(total.AsTensor(), count.AsTensor());
+
+ return base.result();
}
}
}
diff --git a/src/TensorFlowNET.Keras/Metrics/RootMeanSquaredError.cs b/src/TensorFlowNET.Keras/Metrics/RootMeanSquaredError.cs
deleted file mode 100644
index cd7a6968..00000000
--- a/src/TensorFlowNET.Keras/Metrics/RootMeanSquaredError.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class RootMeanSquaredError : Mean
- {
- public RootMeanSquaredError(string name = "root_mean_squared_error", string dtype = null)
- : base(name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SensitivityAtSpecificity.cs b/src/TensorFlowNET.Keras/Metrics/SensitivityAtSpecificity.cs
deleted file mode 100644
index 72793d79..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SensitivityAtSpecificity.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SensitivityAtSpecificity : SensitivitySpecificityBase
- {
- public SensitivityAtSpecificity(float specificity, int num_thresholds = 200, string name = null, string dtype = null) : base(specificity, num_thresholds, name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SensitivitySpecificityBase.cs b/src/TensorFlowNET.Keras/Metrics/SensitivitySpecificityBase.cs
deleted file mode 100644
index 7531cdbb..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SensitivitySpecificityBase.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SensitivitySpecificityBase : Metric
- {
- public SensitivitySpecificityBase(float value, int num_thresholds= 200, string name = null, string dtype = null) : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SparseCategoricalAccuracy.cs b/src/TensorFlowNET.Keras/Metrics/SparseCategoricalAccuracy.cs
deleted file mode 100644
index 5a57907d..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SparseCategoricalAccuracy.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SparseCategoricalAccuracy : MeanMetricWrapper
- {
- public SparseCategoricalAccuracy(string name = "sparse_categorical_accuracy", string dtype = null)
- : base(Metric.sparse_categorical_accuracy, name, dtype)
- {
- }
-
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SparseCategoricalCrossentropy.cs b/src/TensorFlowNET.Keras/Metrics/SparseCategoricalCrossentropy.cs
deleted file mode 100644
index b2513fd8..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SparseCategoricalCrossentropy.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SparseCategoricalCrossentropy : MeanMetricWrapper
- {
- public SparseCategoricalCrossentropy(string name = "sparse_categorical_crossentropy", string dtype = null, bool from_logits = false, int axis = -1)
- : base(Fn, name, dtype)
- {
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Losses.Loss.sparse_categorical_crossentropy(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SparseTopKCategoricalAccuracy.cs b/src/TensorFlowNET.Keras/Metrics/SparseTopKCategoricalAccuracy.cs
deleted file mode 100644
index b02049ad..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SparseTopKCategoricalAccuracy.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SparseTopKCategoricalAccuracy : MeanMetricWrapper
- {
- public SparseTopKCategoricalAccuracy(int k = 5, string name = "sparse_top_k_categorical_accuracy", string dtype = null)
- : base(Fn, name, dtype)
- {
-
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Metric.sparse_top_k_categorical_accuracy(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SpecificityAtSensitivity.cs b/src/TensorFlowNET.Keras/Metrics/SpecificityAtSensitivity.cs
deleted file mode 100644
index 8742e548..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SpecificityAtSensitivity.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- class SpecificityAtSensitivity
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SquaredHinge.cs b/src/TensorFlowNET.Keras/Metrics/SquaredHinge.cs
deleted file mode 100644
index 04a7bef8..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SquaredHinge.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SquaredHinge : MeanMetricWrapper
- {
- public SquaredHinge(string name = "squared_hinge", string dtype = null)
- : base(Losses.Loss.squared_hinge, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/Sum.cs b/src/TensorFlowNET.Keras/Metrics/Sum.cs
index f466a136..bf69980c 100644
--- a/src/TensorFlowNET.Keras/Metrics/Sum.cs
+++ b/src/TensorFlowNET.Keras/Metrics/Sum.cs
@@ -1,14 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
+namespace Tensorflow.Keras.Metrics
{
- public class Sum : Reduce
+ class Sum
{
- public Sum(string name, string dtype = null)
- : base(Reduction.SUM, name, dtype)
- {
- }
}
}
diff --git a/src/TensorFlowNET.Keras/Metrics/SumOverBatchSize.cs b/src/TensorFlowNET.Keras/Metrics/SumOverBatchSize.cs
deleted file mode 100644
index d25654c5..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SumOverBatchSize.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SumOverBatchSize : Reduce
- {
- public SumOverBatchSize(string name = "sum_over_batch_size", string dtype = null) : base(Reduction.SUM_OVER_BATCH_SIZE, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/SumOverBatchSizeMetricWrapper.cs b/src/TensorFlowNET.Keras/Metrics/SumOverBatchSizeMetricWrapper.cs
deleted file mode 100644
index ff1c0497..00000000
--- a/src/TensorFlowNET.Keras/Metrics/SumOverBatchSizeMetricWrapper.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class SumOverBatchSizeMetricWrapper : SumOverBatchSize
- {
- public SumOverBatchSizeMetricWrapper(Func fn, string name, string dtype = null)
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/TopKCategoricalAccuracy.cs b/src/TensorFlowNET.Keras/Metrics/TopKCategoricalAccuracy.cs
deleted file mode 100644
index e2c80fad..00000000
--- a/src/TensorFlowNET.Keras/Metrics/TopKCategoricalAccuracy.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class TopKCategoricalAccuracy : MeanMetricWrapper
- {
- public TopKCategoricalAccuracy(int k = 5, string name = "top_k_categorical_accuracy", string dtype = null)
- : base(Fn, name, dtype)
- {
- }
-
- internal static Tensor Fn(Tensor y_true, Tensor y_pred)
- {
- return Metric.top_k_categorical_accuracy(y_true, y_pred);
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/TrueNegatives.cs b/src/TensorFlowNET.Keras/Metrics/TrueNegatives.cs
deleted file mode 100644
index 7e81a2fd..00000000
--- a/src/TensorFlowNET.Keras/Metrics/TrueNegatives.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class TrueNegatives : _ConfusionMatrixConditionCount
- {
- public TrueNegatives(float thresholds = 0.5F, string name = null, string dtype = null)
- : base(Utils.MetricsUtils.ConfusionMatrix.TRUE_NEGATIVES, thresholds, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/TruePositives.cs b/src/TensorFlowNET.Keras/Metrics/TruePositives.cs
deleted file mode 100644
index 867049be..00000000
--- a/src/TensorFlowNET.Keras/Metrics/TruePositives.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class TruePositives : _ConfusionMatrixConditionCount
- {
- public TruePositives(float thresholds = 0.5F, string name = null, string dtype = null)
- : base(Utils.MetricsUtils.ConfusionMatrix.TRUE_POSITIVES, thresholds, name, dtype)
- {
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Metrics/_ConfusionMatrixConditionCount.cs b/src/TensorFlowNET.Keras/Metrics/_ConfusionMatrixConditionCount.cs
deleted file mode 100644
index 3d2be961..00000000
--- a/src/TensorFlowNET.Keras/Metrics/_ConfusionMatrixConditionCount.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-using static Tensorflow.Keras.Utils.MetricsUtils;
-
-namespace Tensorflow.Keras.Metrics
-{
- public class _ConfusionMatrixConditionCount : Metric
- {
- public _ConfusionMatrixConditionCount(string confusion_matrix_cond, float thresholds= 0.5f, string name= null, string dtype= null)
- : base(name, dtype)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor result()
- {
- throw new NotImplementedException();
- }
-
- public override void update_state(Args args, KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public override void reset_states()
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Model.cs b/src/TensorFlowNET.Keras/Model.cs
deleted file mode 100644
index 738c0488..00000000
--- a/src/TensorFlowNET.Keras/Model.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-/*****************************************************************************
- Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-******************************************************************************/
-
-using Keras.Layers;
-using NumSharp;
-using System;
-using System.Collections.Generic;
-using Tensorflow;
-using static Tensorflow.Binding;
-
-namespace Tensorflow.Keras
-{
- public class Model
- {
- public Tensor Flow;
- List layer_stack;
-
- public TensorShape InputShape;
-
- public Model()
- {
- layer_stack = new List();
- }
- public Model Add(Layer layer)
- {
- layer_stack.Add(layer);
- return this;
- }
- public Model Add(IEnumerable layers)
- {
- layer_stack.AddRange(layers);
- return this;
- }
- public Tensor getFlow()
- {
- try
- {
- return Flow;
- }
-#pragma warning disable CS0168 // Variable is declared but never used
- catch (Exception ex)
-#pragma warning restore CS0168 // Variable is declared but never used
- {
- 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.TensorShape;
- 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;
- using (var sess = tf.Session(graph))
- {
- 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;
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Models.cs b/src/TensorFlowNET.Keras/Models.cs
deleted file mode 100644
index 9321f7fa..00000000
--- a/src/TensorFlowNET.Keras/Models.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using Keras.Layers;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-using Tensorflow.Keras.Engine;
-
-namespace Tensorflow.Keras
-{
- class Models
- {
- public class Model : Keras.Engine.Training.Model{}
-
- public static Layer share_weights(Layer layer) => throw new NotImplementedException();
-
- private static Layer _clone_layer(Layer layer) => throw new NotImplementedException();
-
- private static Layer _insert_ancillary_layers(Model model, Layer ancillary_layers, string[] metrics_names, Node[] new_nodes) => throw new NotImplementedException();
-
- private static Node[] _make_new_nodes(Node[] nodes_by_depth, Func layer_fn, Hashtable layer_map, Hashtable tensor_map) => throw new NotImplementedException();
-
- private static Model _clone_functional_model(Model model, Tensor[] input_tensors = null, Func layer_fn = null) => throw new NotImplementedException();
-
- private static (Hashtable, Layer[]) _clone_layers_and_model_config(Model model, Layer[] input_layers, Func layer_fn) => throw new NotImplementedException();
-
- private static (Layer[], Layer[]) _remove_ancillary_layers(Model model, Hashtable layer_map, Layer[] layers) => throw new NotImplementedException();
-
- private static Sequential _clone_sequential_model(Model model, Tensor[] input_tensors = null, Func layer_fn = null) => throw new NotImplementedException();
-
- public static Model clone_model(Model model, Tensor[] input_tensors = null, Func layer_fn = null) => throw new NotImplementedException();
-
- private static void _in_place_subclassed_model_reset(Model model) => throw new NotImplementedException();
-
- private static void _reset_build_compile_trackers(Model model) => throw new NotImplementedException();
-
- public static void in_place_subclassed_model_state_restoration(Model model) => throw new NotImplementedException();
-
- public static void clone_and_build_model(Model model, Tensor[] input_tensors= null, Tensor[] target_tensors= null, object custom_objects= null,
- bool compile_clone= true, bool in_place_reset= false, IVariableV1 optimizer_iterations= null, Hashtable optimizer_config= null)
- => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/Adadelta.cs b/src/TensorFlowNET.Keras/Optimizer/Adadelta.cs
deleted file mode 100644
index e5d72976..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/Adadelta.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Adadelta : Optimizer
- {
- public Adadelta(float lr= 0.01f, float rho = 0.95f, float? epsilon = null, float decay = 0) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/Adagrad.cs b/src/TensorFlowNET.Keras/Optimizer/Adagrad.cs
deleted file mode 100644
index 4353d79b..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/Adagrad.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Adagrad : Optimizer
- {
- public Adagrad(float lr= 0.01f, float? epsilon = null, float decay = 0) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/Adam.cs b/src/TensorFlowNET.Keras/Optimizer/Adam.cs
deleted file mode 100644
index 15053284..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/Adam.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Adam : Optimizer
- {
- public Adam(float lr= 0.001f, float beta_1 = 0.9f, float beta_2 = 0.99f, float? epsilon = null, float decay = 0) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/Adamax.cs b/src/TensorFlowNET.Keras/Optimizer/Adamax.cs
deleted file mode 100644
index 9581c6dc..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/Adamax.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Adamax : Optimizer
- {
- public Adamax(float lr = 0.002f, float beta_1 = 0.9f, float beta_2 = 0.999f, float? epsilon = null, float decay = 0) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/Nadam.cs b/src/TensorFlowNET.Keras/Optimizer/Nadam.cs
deleted file mode 100644
index b933570f..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/Nadam.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Nadam : Optimizer
- {
- public Nadam(float lr = 0.002f, float beta_1 = 0.9f, float beta_2 = 0.999f, float? epsilon = null, float schedule_decay = 0.004f) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/Optimizer.cs b/src/TensorFlowNET.Keras/Optimizer/Optimizer.cs
deleted file mode 100644
index ec8bd68a..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/Optimizer.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using NumSharp;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class Optimizer
- {
- public Optimizer(KwArgs kwargs)
- {
- throw new NotImplementedException();
- }
-
- public virtual Tensor[] get_updates(Tensor loss, variables @params)
- {
- return null;
- }
-
- public virtual Tensor[] get_gradients(Tensor loss, variables @params) => throw new NotImplementedException();
-
- public virtual void set_weights(NDArray[] weights) => throw new NotImplementedException();
-
- public virtual NDArray[] get_weights() => throw new NotImplementedException();
-
- public virtual Hashtable get_config() => throw new NotImplementedException();
-
- public static string serialize(Optimizer optimizer) => throw new NotImplementedException();
-
- public static Optimizer deserialize(string config, object custom_objects = null) => throw new NotImplementedException();
-
- public static Optimizer get(object identifier) => throw new NotImplementedException();
-
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/RMSprop.cs b/src/TensorFlowNET.Keras/Optimizer/RMSprop.cs
deleted file mode 100644
index 79894831..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/RMSprop.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class RMSprop : Optimizer
- {
- public RMSprop(float lr= 0.01f, float rho = 0f, float? epsilon = null, float decay = 0) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Keras/Optimizer/SGD.cs b/src/TensorFlowNET.Keras/Optimizer/SGD.cs
deleted file mode 100644
index 17063c54..00000000
--- a/src/TensorFlowNET.Keras/Optimizer/SGD.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras
-{
- public class SGD : Optimizer
- {
- public SGD(float lr= 0.01f, float momentum= 0, float decay= 0, bool nesterov= false) : base(null)
- {
- throw new NotImplementedException();
- }
-
- public override Tensor[] get_updates(Tensor loss, variables @params)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/Adam.cs b/src/TensorFlowNET.Keras/Optimizers/Adam.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/Adam.cs
rename to src/TensorFlowNET.Keras/Optimizers/Adam.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/DeviceDType.cs b/src/TensorFlowNET.Keras/Optimizers/DeviceDType.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/DeviceDType.cs
rename to src/TensorFlowNET.Keras/Optimizers/DeviceDType.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/IOptimizer.cs b/src/TensorFlowNET.Keras/Optimizers/IOptimizer.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/IOptimizer.cs
rename to src/TensorFlowNET.Keras/Optimizers/IOptimizer.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/LearningRateSchedule.cs b/src/TensorFlowNET.Keras/Optimizers/LearningRateSchedule.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/LearningRateSchedule.cs
rename to src/TensorFlowNET.Keras/Optimizers/LearningRateSchedule.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs b/src/TensorFlowNET.Keras/Optimizers/OptimizerApi.cs
similarity index 95%
rename from src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs
rename to src/TensorFlowNET.Keras/Optimizers/OptimizerApi.cs
index 68010702..8ef8cc2b 100644
--- a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs
+++ b/src/TensorFlowNET.Keras/Optimizers/OptimizerApi.cs
@@ -53,5 +53,8 @@ namespace Tensorflow.Keras.Optimizers
Centered = centered,
Name = name
});
+
+ public SGD SGD(float learning_rate)
+ => new SGD(learning_rate);
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerV2.cs b/src/TensorFlowNET.Keras/Optimizers/OptimizerV2.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/OptimizerV2.cs
rename to src/TensorFlowNET.Keras/Optimizers/OptimizerV2.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/PolynomialDecay.cs b/src/TensorFlowNET.Keras/Optimizers/PolynomialDecay.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/PolynomialDecay.cs
rename to src/TensorFlowNET.Keras/Optimizers/PolynomialDecay.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/RMSprop.cs b/src/TensorFlowNET.Keras/Optimizers/RMSprop.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/RMSprop.cs
rename to src/TensorFlowNET.Keras/Optimizers/RMSprop.cs
diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/SGD.cs b/src/TensorFlowNET.Keras/Optimizers/SGD.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Optimizers/SGD.cs
rename to src/TensorFlowNET.Keras/Optimizers/SGD.cs
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/Adadelta.cs b/src/TensorFlowNET.Keras/OptimizersV2/Adadelta.cs
deleted file mode 100644
index 1ba244da..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/Adadelta.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class Adadelta
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/Adagrad.cs b/src/TensorFlowNET.Keras/OptimizersV2/Adagrad.cs
deleted file mode 100644
index 9781c898..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/Adagrad.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class Adagrad
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/Adam.cs b/src/TensorFlowNET.Keras/OptimizersV2/Adam.cs
deleted file mode 100644
index 7e08d517..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/Adam.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class Adam
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/Adamax.cs b/src/TensorFlowNET.Keras/OptimizersV2/Adamax.cs
deleted file mode 100644
index 73f37ad9..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/Adamax.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class Adamax
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/Ftrl.cs b/src/TensorFlowNET.Keras/OptimizersV2/Ftrl.cs
deleted file mode 100644
index 758698a8..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/Ftrl.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class Ftrl
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/LearningRateSchedule.cs b/src/TensorFlowNET.Keras/OptimizersV2/LearningRateSchedule.cs
deleted file mode 100644
index 2dd3df40..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/LearningRateSchedule.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class LearningRateSchedule
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/Nadam.cs b/src/TensorFlowNET.Keras/OptimizersV2/Nadam.cs
deleted file mode 100644
index ec247c41..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/Nadam.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class Nadam
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/OptimizerV2.cs b/src/TensorFlowNET.Keras/OptimizersV2/OptimizerV2.cs
deleted file mode 100644
index ecb9780a..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/OptimizerV2.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class OptimizerV2
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/RMSProp.cs b/src/TensorFlowNET.Keras/OptimizersV2/RMSProp.cs
deleted file mode 100644
index 62d9f57b..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/RMSProp.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class RMSProp
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/OptimizersV2/SGD.cs b/src/TensorFlowNET.Keras/OptimizersV2/SGD.cs
deleted file mode 100644
index 8e72c486..00000000
--- a/src/TensorFlowNET.Keras/OptimizersV2/SGD.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.OptimizersV2
-{
- class SGD
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Premade/LinearModel.cs b/src/TensorFlowNET.Keras/Premade/LinearModel.cs
deleted file mode 100644
index 7b3d1276..00000000
--- a/src/TensorFlowNET.Keras/Premade/LinearModel.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Premade
-{
- class LinearModel
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Premade/WideDeepModel.cs b/src/TensorFlowNET.Keras/Premade/WideDeepModel.cs
deleted file mode 100644
index 108c689b..00000000
--- a/src/TensorFlowNET.Keras/Premade/WideDeepModel.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Premade
-{
- class WideDeepModel
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Preprocessing/Image.cs b/src/TensorFlowNET.Keras/Preprocessing/Image.cs
deleted file mode 100644
index ad9c9b12..00000000
--- a/src/TensorFlowNET.Keras/Preprocessing/Image.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Preprocessing
-{
- class Image
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Preprocessing/Sequence.cs b/src/TensorFlowNET.Keras/Preprocessing/Sequence.cs
deleted file mode 100644
index 3773001f..00000000
--- a/src/TensorFlowNET.Keras/Preprocessing/Sequence.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Preprocessing
-{
- class Sequence
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Preprocessing/Text.cs b/src/TensorFlowNET.Keras/Preprocessing/Text.cs
deleted file mode 100644
index 7f6012c7..00000000
--- a/src/TensorFlowNET.Keras/Preprocessing/Text.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Preprocessing
-{
- class Text
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs b/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs
rename to src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.cs
diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs b/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs
rename to src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs
diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs b/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs
rename to src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs
diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.cs b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.cs
rename to src/TensorFlowNET.Keras/Preprocessings/Preprocessing.cs
diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
similarity index 88%
rename from src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
rename to src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
index 6e1cfa73..4966a907 100644
--- a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
+++ b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
@@ -1,4 +1,5 @@
using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras
{
@@ -42,14 +43,14 @@ namespace Tensorflow.Keras
if (color_mode == "rgb")
num_channels = 3;
// C:/Users/haipi/.keras/datasets/flower_photos
- var (image_paths, label_list, class_name_list) = tf.keras.preprocessing.dataset_utils.index_directory(directory,
+ var (image_paths, label_list, class_name_list) = keras.preprocessing.dataset_utils.index_directory(directory,
formats: WHITELIST_FORMATS,
class_names: class_names,
shuffle: shuffle,
seed: seed,
follow_links: follow_links);
- (image_paths, label_list) = tf.keras.preprocessing.dataset_utils.get_training_or_validation_split(image_paths, label_list, validation_split, subset);
+ (image_paths, label_list) = keras.preprocessing.dataset_utils.get_training_or_validation_split(image_paths, label_list, validation_split, subset);
var dataset = paths_and_labels_to_dataset(image_paths, image_size, num_channels, label_list, label_mode, class_name_list.Length, interpolation);
if (shuffle)
diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs
rename to src/TensorFlowNET.Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs
diff --git a/src/TensorFlowNET.Keras/Range.cs b/src/TensorFlowNET.Keras/Range.cs
new file mode 100644
index 00000000..892a628e
--- /dev/null
+++ b/src/TensorFlowNET.Keras/Range.cs
@@ -0,0 +1,274 @@
+// https://github.com/dotnet/corefx/blob/1597b894a2e9cac668ce6e484506eca778a85197/src/Common/src/CoreLib/System/Index.cs
+// https://github.com/dotnet/corefx/blob/1597b894a2e9cac668ce6e484506eca778a85197/src/Common/src/CoreLib/System/Range.cs
+
+using System.Runtime.CompilerServices;
+
+namespace System
+{
+ /// Represent a type can be used to index a collection either from the start or the end.
+ ///
+ /// Index is used by the C# compiler to support the new index syntax
+ ///
+ /// int[] someArray = new int[5] { 1, 2, 3, 4, 5 } ;
+ /// int lastElement = someArray[^1]; // lastElement = 5
+ ///
+ ///
+ internal readonly struct Index : IEquatable
+ {
+ private readonly int _value;
+
+ /// Construct an Index using a value and indicating if the index is from the start or from the end.
+ /// The index value. it has to be zero or positive number.
+ /// Indicating if the index is from the start or from the end.
+ ///
+ /// If the Index constructed from the end, index value 1 means pointing at the last element and index value 0 means pointing at beyond last element.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Index(int value, bool fromEnd = false)
+ {
+ if (value < 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative");
+ }
+
+ if (fromEnd)
+ _value = ~value;
+ else
+ _value = value;
+ }
+
+ // The following private constructors mainly created for perf reason to avoid the checks
+ private Index(int value)
+ {
+ _value = value;
+ }
+
+ /// Create an Index pointing at first element.
+ public static Index Start => new Index(0);
+
+ /// Create an Index pointing at beyond last element.
+ public static Index End => new Index(~0);
+
+ /// Create an Index from the start at the position indicated by the value.
+ /// The index value from the start.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Index FromStart(int value)
+ {
+ if (value < 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative");
+ }
+
+ return new Index(value);
+ }
+
+ /// Create an Index from the end at the position indicated by the value.
+ /// The index value from the end.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Index FromEnd(int value)
+ {
+ if (value < 0)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative");
+ }
+
+ return new Index(~value);
+ }
+
+ /// Returns the index value.
+ public int Value
+ {
+ get
+ {
+ if (_value < 0)
+ {
+ return ~_value;
+ }
+ else
+ {
+ return _value;
+ }
+ }
+ }
+
+ /// Indicates whether the index is from the start or the end.
+ public bool IsFromEnd => _value < 0;
+
+ /// Calculate the offset from the start using the giving collection length.
+ /// The length of the collection that the Index will be used with. length has to be a positive value
+ ///
+ /// For performance reason, we don't validate the input length parameter and the returned offset value against negative values.
+ /// we don't validate either the returned offset is greater than the input length.
+ /// It is expected Index will be used with collections which always have non negative length/count. If the returned offset is negative and
+ /// then used to index a collection will get out of range exception which will be same affect as the validation.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public int GetOffset(int length)
+ {
+ var offset = _value;
+ if (IsFromEnd)
+ {
+ // offset = length - (~value)
+ // offset = length + (~(~value) + 1)
+ // offset = length + value + 1
+
+ offset += length + 1;
+ }
+ return offset;
+ }
+
+ /// Indicates whether the current Index object is equal to another object of the same type.
+ /// An object to compare with this object
+ public override bool Equals(object? value) => value is Index && _value == ((Index)value)._value;
+
+ /// Indicates whether the current Index object is equal to another Index object.
+ /// An object to compare with this object
+ public bool Equals(Index other) => _value == other._value;
+
+ /// Returns the hash code for this instance.
+ public override int GetHashCode() => _value;
+
+ /// Converts integer number to an Index.
+ public static implicit operator Index(int value) => FromStart(value);
+
+ /// Converts the value of the current Index object to its equivalent string representation.
+ public override string ToString()
+ {
+ if (IsFromEnd)
+ return "^" + ((uint)Value).ToString();
+
+ return ((uint)Value).ToString();
+ }
+ }
+
+ /// Represent a range has start and end indexes.
+ ///
+ /// Range is used by the C# compiler to support the range syntax.
+ ///
+ /// int[] someArray = new int[5] { 1, 2, 3, 4, 5 };
+ /// int[] subArray1 = someArray[0..2]; // { 1, 2 }
+ /// int[] subArray2 = someArray[1..^0]; // { 2, 3, 4, 5 }
+ ///
+ ///
+ internal readonly struct Range : IEquatable
+ {
+ /// Represent the inclusive start index of the Range.
+ public Index Start { get; }
+
+ /// Represent the exclusive end index of the Range.
+ public Index End { get; }
+
+ /// Construct a Range object using the start and end indexes.
+ /// Represent the inclusive start index of the range.
+ /// Represent the exclusive end index of the range.
+ public Range(Index start, Index end)
+ {
+ Start = start;
+ End = end;
+ }
+
+ /// Indicates whether the current Range object is equal to another object of the same type.
+ /// An object to compare with this object
+ public override bool Equals(object? value) =>
+ value is Range r &&
+ r.Start.Equals(Start) &&
+ r.End.Equals(End);
+
+ /// Indicates whether the current Range object is equal to another Range object.
+ /// An object to compare with this object
+ public bool Equals(Range other) => other.Start.Equals(Start) && other.End.Equals(End);
+
+ /// Returns the hash code for this instance.
+ public override int GetHashCode()
+ {
+ return Start.GetHashCode() * 31 + End.GetHashCode();
+ }
+
+ /// Converts the value of the current Range object to its equivalent string representation.
+ public override string ToString()
+ {
+ return Start + ".." + End;
+ }
+
+ /// Create a Range object starting from start index to the end of the collection.
+ public static Range StartAt(Index start) => new Range(start, Index.End);
+
+ /// Create a Range object starting from first element in the collection to the end Index.
+ public static Range EndAt(Index end) => new Range(Index.Start, end);
+
+ /// Create a Range object starting from first element to the end.
+ public static Range All => new Range(Index.Start, Index.End);
+
+ /// Calculate the start offset and length of range object using a collection length.
+ /// The length of the collection that the range will be used with. length has to be a positive value.
+ ///
+ /// For performance reason, we don't validate the input length parameter against negative values.
+ /// It is expected Range will be used with collections which always have non negative length/count.
+ /// We validate the range is inside the length scope though.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public (int Offset, int Length) GetOffsetAndLength(int length)
+ {
+ int start;
+ var startIndex = Start;
+ if (startIndex.IsFromEnd)
+ start = length - startIndex.Value;
+ else
+ start = startIndex.Value;
+
+ int end;
+ var endIndex = End;
+ if (endIndex.IsFromEnd)
+ end = length - endIndex.Value;
+ else
+ end = endIndex.Value;
+
+ if ((uint)end > (uint)length || (uint)start > (uint)end)
+ {
+ throw new ArgumentOutOfRangeException(nameof(length));
+ }
+
+ return (start, end - start);
+ }
+ }
+}
+
+namespace System.Runtime.CompilerServices
+{
+ internal static class RuntimeHelpers
+ {
+ ///
+ /// Slices the specified array using the specified range.
+ ///
+ public static T[] GetSubArray(T[] array, Range range)
+ {
+ if (array == null)
+ {
+ throw new ArgumentNullException(nameof(array));
+ }
+
+ (int offset, int length) = range.GetOffsetAndLength(array.Length);
+
+ if (default(T) != null || typeof(T[]) == array.GetType())
+ {
+ // We know the type of the array to be exactly T[].
+
+ if (length == 0)
+ {
+ return Array.Empty();
+ }
+
+ var dest = new T[length];
+ Array.Copy(array, offset, dest, 0, length);
+ return dest;
+ }
+ else
+ {
+ // The array is actually a U[] where U:T.
+ var dest = (T[])Array.CreateInstance(array.GetType().GetElementType(), length);
+ Array.Copy(array, offset, dest, 0, length);
+ return dest;
+ }
+ }
+ }
+}
diff --git a/src/TensorFlowNET.Core/Keras/Regularizers.cs b/src/TensorFlowNET.Keras/Regularizers.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Regularizers.cs
rename to src/TensorFlowNET.Keras/Regularizers.cs
diff --git a/src/TensorFlowNET.Keras/Regularizers/L1L2.cs b/src/TensorFlowNET.Keras/Regularizers/L1L2.cs
deleted file mode 100644
index 927b3319..00000000
--- a/src/TensorFlowNET.Keras/Regularizers/L1L2.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Regularizers
-{
- public class L1L2 : Regularizer
- {
- public L1L2(float l1 = 0f, float l2 = 0f)
- {
- throw new NotImplementedException();
- }
-
- public override float call(Tensor x)
- {
- throw new NotImplementedException();
- }
-
- public override Hashtable get_config()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Regularizers/L2.cs b/src/TensorFlowNET.Keras/Regularizers/L2.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Regularizers/L2.cs
rename to src/TensorFlowNET.Keras/Regularizers/L2.cs
diff --git a/src/TensorFlowNET.Keras/Regularizers/Regularizer.cs b/src/TensorFlowNET.Keras/Regularizers/Regularizer.cs
deleted file mode 100644
index 047b035f..00000000
--- a/src/TensorFlowNET.Keras/Regularizers/Regularizer.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Regularizers
-{
- public abstract class Regularizer
- {
- public virtual float call(Tensor x)
- {
- return 0f;
- }
-
- public static Regularizer from_config(Hashtable hashtable) => throw new NotImplementedException();
-
- public virtual Hashtable get_config() => throw new NotImplementedException();
-
- public static Regularizer l1(float l = 0.01f)
- {
- return new L1L2(l1: l);
- }
-
- public static Regularizer l2(float l = 0.01f)
- {
- return new L1L2(l2: l);
- }
-
- public static Regularizer l1_l2(float l1 = 0.01f, float l2 = 0.01f)
- {
- return new L1L2(l1, l2);
- }
-
- public static string serialize(Regularizer regularizer) => throw new NotImplementedException();
-
- public static string deserialize(string config, dynamic custom_objects = null) => throw new NotImplementedException();
-
- public static Regularizer get(object identifier) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/HDF5Format.cs b/src/TensorFlowNET.Keras/Saving/HDF5Format.cs
deleted file mode 100644
index 52ed591c..00000000
--- a/src/TensorFlowNET.Keras/Saving/HDF5Format.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving
-{
- class HDF5Format
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/ModelConfig.cs b/src/TensorFlowNET.Keras/Saving/ModelConfig.cs
deleted file mode 100644
index 934e9429..00000000
--- a/src/TensorFlowNET.Keras/Saving/ModelConfig.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving
-{
- class ModelConfig
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/Save.cs b/src/TensorFlowNET.Keras/Saving/Save.cs
deleted file mode 100644
index f4469902..00000000
--- a/src/TensorFlowNET.Keras/Saving/Save.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving
-{
- class Save
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/BaseSerialization.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/BaseSerialization.cs
deleted file mode 100644
index 90102a06..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/BaseSerialization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class BaseSerialization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/Constants.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/Constants.cs
deleted file mode 100644
index 85daf45d..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/Constants.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class Constants
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/LayerSerialization.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/LayerSerialization.cs
deleted file mode 100644
index bbf067fb..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/LayerSerialization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class LayerSerialization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/Load.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/Load.cs
deleted file mode 100644
index 2508f7f6..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/Load.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class Load
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/ModelSerialization.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/ModelSerialization.cs
deleted file mode 100644
index 4a3e1336..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/ModelSerialization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class ModelSerialization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/NetworkSerialization.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/NetworkSerialization.cs
deleted file mode 100644
index 6eb17318..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/NetworkSerialization.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class NetworkSerialization
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/Save.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/Save.cs
deleted file mode 100644
index 45933877..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/Save.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class Save
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/SaveImpl.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/SaveImpl.cs
deleted file mode 100644
index 67a5f0dc..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/SaveImpl.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class SaveImpl
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/SerializedAttributes.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/SerializedAttributes.cs
deleted file mode 100644
index d1b19ccf..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/SerializedAttributes.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class SerializedAttributes
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModel/Utils.cs b/src/TensorFlowNET.Keras/Saving/SavedModel/Utils.cs
deleted file mode 100644
index 8beebdea..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModel/Utils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving.SavedModel
-{
- class Utils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavedModelExperimental.cs b/src/TensorFlowNET.Keras/Saving/SavedModelExperimental.cs
deleted file mode 100644
index 0455b622..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavedModelExperimental.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving
-{
- class SavedModelExperimental
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Saving/SavingUtils.cs b/src/TensorFlowNET.Keras/Saving/SavingUtils.cs
deleted file mode 100644
index b5f03de8..00000000
--- a/src/TensorFlowNET.Keras/Saving/SavingUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Saving
-{
- class SavingUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Sequence.cs b/src/TensorFlowNET.Keras/Sequence.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Sequence.cs
rename to src/TensorFlowNET.Keras/Sequence.cs
diff --git a/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj b/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
index a9ea481a..9d36a069 100644
--- a/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
+++ b/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
@@ -3,6 +3,7 @@
netstandard2.0
Tensorflow.Keras
+ 8.0
Tensorflow.Keras
AnyCPU;x64
diff --git a/src/TensorFlowNET.Keras/Utils/ConvUtils.cs b/src/TensorFlowNET.Keras/Utils/ConvUtils.cs
deleted file mode 100644
index 604db158..00000000
--- a/src/TensorFlowNET.Keras/Utils/ConvUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class ConvUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/DataUtils.cs b/src/TensorFlowNET.Keras/Utils/DataUtils.cs
deleted file mode 100644
index 2f5e3646..00000000
--- a/src/TensorFlowNET.Keras/Utils/DataUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class DataUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/GenericUtils.cs b/src/TensorFlowNET.Keras/Utils/GenericUtils.cs
deleted file mode 100644
index edc8f7fe..00000000
--- a/src/TensorFlowNET.Keras/Utils/GenericUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class GenericUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/IOUtils.cs b/src/TensorFlowNET.Keras/Utils/IOUtils.cs
deleted file mode 100644
index 0cc9c930..00000000
--- a/src/TensorFlowNET.Keras/Utils/IOUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class IOUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/KernelizedUtils.cs b/src/TensorFlowNET.Keras/Utils/KernelizedUtils.cs
deleted file mode 100644
index 30c950c6..00000000
--- a/src/TensorFlowNET.Keras/Utils/KernelizedUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class KernelizedUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/LayerUtils.cs b/src/TensorFlowNET.Keras/Utils/LayerUtils.cs
deleted file mode 100644
index 70ffa9a4..00000000
--- a/src/TensorFlowNET.Keras/Utils/LayerUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class LayerUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/LossesUtils.cs b/src/TensorFlowNET.Keras/Utils/LossesUtils.cs
deleted file mode 100644
index 8fd35ca6..00000000
--- a/src/TensorFlowNET.Keras/Utils/LossesUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class LossesUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/MetricsUtils.cs b/src/TensorFlowNET.Keras/Utils/MetricsUtils.cs
deleted file mode 100644
index 1e51b099..00000000
--- a/src/TensorFlowNET.Keras/Utils/MetricsUtils.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- public class MetricsUtils
- {
- public static class Reduction
- {
- public const string SUM = "sum";
- public const string SUM_OVER_BATCH_SIZE = "sum_over_batch_size";
- public const string WEIGHTED_MEAN = "weighted_mean";
- }
-
- public static class ConfusionMatrix
- {
- public const string TRUE_POSITIVES = "tp";
- public const string FALSE_POSITIVES = "fp";
- public const string TRUE_NEGATIVES = "tn";
- public const string FALSE_NEGATIVES = "fn";
- }
-
- public static class AUCCurve
- {
- public const string ROC = "ROC";
- public const string PR = "PR";
-
- public static string from_str(string key) => throw new NotImplementedException();
- }
-
- public static class AUCSummationMethod
- {
- public const string INTERPOLATION = "interpolation";
- public const string MAJORING = "majoring";
- public const string MINORING = "minoring";
-
- public static string from_str(string key) => throw new NotImplementedException();
- }
-
- public static dynamic update_state_wrapper(Func> update_state_fn) => throw new NotImplementedException();
-
- public static dynamic result_wrapper(Func result_fn) => throw new NotImplementedException();
-
- public static WeakReference weakmethod(MethodInfo method) => throw new NotImplementedException();
-
- public static void assert_thresholds_range(float[] thresholds) => throw new NotImplementedException();
-
- public static void parse_init_thresholds(float[] thresholds, float default_threshold = 0.5f) => throw new NotImplementedException();
-
- public static Operation update_confusion_matrix_variables(variables variables_to_update, Tensor y_true, Tensor y_pred, float[] thresholds,
- int? top_k= null,int? class_id= null, Tensor sample_weight= null, bool multi_label= false,
- Tensor label_weights= null) => throw new NotImplementedException();
-
- private static Tensor _filter_top_k(Tensor x, int k) => throw new NotImplementedException();
-
- private static (Tensor[], Tensor) ragged_assert_compatible_and_get_flat_values(Tensor[] values, Tensor mask = null) => throw new NotImplementedException();
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/ModeKeys.cs b/src/TensorFlowNET.Keras/Utils/ModeKeys.cs
deleted file mode 100644
index 03ba5e44..00000000
--- a/src/TensorFlowNET.Keras/Utils/ModeKeys.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class ModeKeys
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/MultiGpuUtils.cs b/src/TensorFlowNET.Keras/Utils/MultiGpuUtils.cs
deleted file mode 100644
index 347438a2..00000000
--- a/src/TensorFlowNET.Keras/Utils/MultiGpuUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class MultiGpuUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/NPUtils.cs b/src/TensorFlowNET.Keras/Utils/NPUtils.cs
deleted file mode 100644
index e8bbe68e..00000000
--- a/src/TensorFlowNET.Keras/Utils/NPUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class NPUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/TFUtils.cs b/src/TensorFlowNET.Keras/Utils/TFUtils.cs
deleted file mode 100644
index 8be02c8d..00000000
--- a/src/TensorFlowNET.Keras/Utils/TFUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class TFUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/VersionUtils.cs b/src/TensorFlowNET.Keras/Utils/VersionUtils.cs
deleted file mode 100644
index a18d70d9..00000000
--- a/src/TensorFlowNET.Keras/Utils/VersionUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class VersionUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Keras/Utils/VisUtils.cs b/src/TensorFlowNET.Keras/Utils/VisUtils.cs
deleted file mode 100644
index 79ac0132..00000000
--- a/src/TensorFlowNET.Keras/Utils/VisUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Utils
-{
- class VisUtils
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs b/src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
similarity index 94%
rename from src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs
rename to src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
index dc03bbb2..f0d314d2 100644
--- a/src/TensorFlowNET.Core/Keras/Utils/base_layer_utils.cs
+++ b/src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
@@ -21,6 +21,7 @@ using System.Linq;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace Tensorflow.Keras.Utils
{
@@ -94,14 +95,14 @@ namespace Tensorflow.Keras.Utils
{
var graph = ops.get_default_graph();
Dictionary name_uid_map = null;
- if (tf.keras.backend.PER_GRAPH_LAYER_NAME_UIDS.ContainsKey(graph))
+ if (keras.backend.PER_GRAPH_LAYER_NAME_UIDS.ContainsKey(graph))
{
- name_uid_map = tf.keras.backend.PER_GRAPH_LAYER_NAME_UIDS[graph];
+ name_uid_map = keras.backend.PER_GRAPH_LAYER_NAME_UIDS[graph];
}
else
{
name_uid_map = new Dictionary();
- tf.keras.backend.PER_GRAPH_LAYER_NAME_UIDS[graph] = name_uid_map;
+ keras.backend.PER_GRAPH_LAYER_NAME_UIDS[graph] = name_uid_map;
}
return name_uid_map;
@@ -143,7 +144,7 @@ namespace Tensorflow.Keras.Utils
{
tf_with(ops.init_scope(), delegate
{
- constants[i] = tf.keras.backend.eval_in_eager_or_function(op_input);
+ constants[i] = keras.backend.eval_in_eager_or_function(op_input);
});
}
}
diff --git a/src/TensorFlowNET.Core/Keras/Utils/conv_utils.cs b/src/TensorFlowNET.Keras/Utils/conv_utils.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Utils/conv_utils.cs
rename to src/TensorFlowNET.Keras/Utils/conv_utils.cs
diff --git a/src/TensorFlowNET.Core/Keras/Utils/generic_utils.cs b/src/TensorFlowNET.Keras/Utils/generic_utils.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Utils/generic_utils.cs
rename to src/TensorFlowNET.Keras/Utils/generic_utils.cs
diff --git a/src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs b/src/TensorFlowNET.Keras/Utils/layer_utils.cs
similarity index 95%
rename from src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs
rename to src/TensorFlowNET.Keras/Utils/layer_utils.cs
index 71a417de..34f553d4 100644
--- a/src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs
+++ b/src/TensorFlowNET.Keras/Utils/layer_utils.cs
@@ -17,7 +17,7 @@ namespace Tensorflow.Keras.Utils
if (!sequential_like)
{
sequential_like = true;
- var nodes = new List();
+ var nodes = new List();
foreach (var v in model.NodesByDepth)
{
@@ -59,7 +59,7 @@ namespace Tensorflow.Keras.Utils
}
string[] to_display;
- var relevant_nodes = new List();
+ var relevant_nodes = new List();
if (sequential_like)
{
@@ -130,7 +130,7 @@ namespace Tensorflow.Keras.Utils
/// Prints a summary for a single layer.
///
///
- static void print_layer_summary(Layer layer, int[] positions)
+ static void print_layer_summary(ILayer layer, int[] positions)
{
var name = layer.Name;
@@ -144,7 +144,7 @@ namespace Tensorflow.Keras.Utils
print_row(fields, positions);
}
- static void print_layer_summary_with_connections(Layer layer, int[] positions, List relevant_nodes)
+ static void print_layer_summary_with_connections(ILayer layer, int[] positions, List relevant_nodes)
{
var connections = new List();
foreach (var node in layer.InboundNodes)
diff --git a/src/TensorFlowNET.Core/Keras/Utils/losses_utils.cs b/src/TensorFlowNET.Keras/Utils/losses_utils.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Utils/losses_utils.cs
rename to src/TensorFlowNET.Keras/Utils/losses_utils.cs
diff --git a/src/TensorFlowNET.Core/Keras/Utils/tf_utils.cs b/src/TensorFlowNET.Keras/Utils/tf_utils.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/Utils/tf_utils.cs
rename to src/TensorFlowNET.Keras/Utils/tf_utils.cs
diff --git a/src/TensorFlowNET.Keras/Wrappers/ScikitLearn.cs b/src/TensorFlowNET.Keras/Wrappers/ScikitLearn.cs
deleted file mode 100644
index 0704509a..00000000
--- a/src/TensorFlowNET.Keras/Wrappers/ScikitLearn.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tensorflow.Keras.Wrappers
-{
- class ScikitLearn
- {
- }
-}
diff --git a/src/TensorFlowNET.Core/Keras/defaultdict.cs b/src/TensorFlowNET.Keras/defaultdict.cs
similarity index 100%
rename from src/TensorFlowNET.Core/Keras/defaultdict.cs
rename to src/TensorFlowNET.Keras/defaultdict.cs
diff --git a/src/TensorFlowNET.Core/APIs/tf.layers.cs b/src/TensorFlowNET.Keras/tf.layers.cs
similarity index 99%
rename from src/TensorFlowNET.Core/APIs/tf.layers.cs
rename to src/TensorFlowNET.Keras/tf.layers.cs
index 11dae546..bc1bb410 100644
--- a/src/TensorFlowNET.Core/APIs/tf.layers.cs
+++ b/src/TensorFlowNET.Keras/tf.layers.cs
@@ -16,14 +16,13 @@
using System.Collections.Generic;
using System.Linq;
-using Tensorflow.Keras;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Layers;
using static Tensorflow.Binding;
-namespace Tensorflow
+namespace Tensorflow.Keras
{
- public partial class tensorflow
+ public class tensorflow_layers
{
public layers_internal layers { get; } = new layers_internal();
@@ -65,7 +64,7 @@ namespace Tensorflow
Trainable = trainable,
Name = name
});
-
+
return layer.Apply(inputs);
}
diff --git a/src/TensorFlowNET.Core/APIs/tf.keras.cs b/src/TensorFlowNET.Keras/tf.optimizers.cs
similarity index 71%
rename from src/TensorFlowNET.Core/APIs/tf.keras.cs
rename to src/TensorFlowNET.Keras/tf.optimizers.cs
index 7b3d4c22..381d2b10 100644
--- a/src/TensorFlowNET.Core/APIs/tf.keras.cs
+++ b/src/TensorFlowNET.Keras/tf.optimizers.cs
@@ -1,5 +1,5 @@
/*****************************************************************************
- Copyright 2020 Haiping Chen. All Rights Reserved.
+ Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,10 +14,17 @@
limitations under the License.
******************************************************************************/
-namespace Tensorflow
+using Tensorflow.Keras.Optimizers;
+
+namespace Tensorflow.Keras
{
- public partial class tensorflow
+ public class tensorflow_backup
{
- public KerasApi keras { get; } = new KerasApi();
+ public KerasOptimizers optimizers => new KerasOptimizers();
+
+ public class KerasOptimizers
+ {
+
+ }
}
}
diff --git a/test/TensorFlowNET.UnitTest/EagerModeTestBase.cs b/test/TensorFlowNET.UnitTest/EagerModeTestBase.cs
index 4e837aa3..84ce57d9 100644
--- a/test/TensorFlowNET.UnitTest/EagerModeTestBase.cs
+++ b/test/TensorFlowNET.UnitTest/EagerModeTestBase.cs
@@ -3,16 +3,15 @@ using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow;
-using Tensorflow.Keras.Engine;
using Tensorflow.Keras.Layers;
using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace TensorFlowNET.UnitTest
{
public class EagerModeTestBase : PythonTest
{
- protected KerasApi keras = tf.keras;
- protected LayersApi layers = tf.keras.layers;
+ protected LayersApi layers = keras.layers;
[TestInitialize]
public void TestInit()
diff --git a/test/TensorFlowNET.UnitTest/Keras/LayersTest.cs b/test/TensorFlowNET.UnitTest/Keras/LayersTest.cs
index d5ed8cd7..cf935b84 100644
--- a/test/TensorFlowNET.UnitTest/Keras/LayersTest.cs
+++ b/test/TensorFlowNET.UnitTest/Keras/LayersTest.cs
@@ -2,11 +2,8 @@
using System;
using System.Collections.Generic;
using System.Text;
-using Tensorflow.Keras.Engine;
-using Tensorflow.Keras.Layers;
using NumSharp;
-using Tensorflow.UnitTest;
-using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace TensorFlowNET.UnitTest.Keras
{
@@ -16,12 +13,11 @@ namespace TensorFlowNET.UnitTest.Keras
[TestClass]
public class LayersTest : EagerModeTestBase
{
-
[TestMethod]
public void Sequential()
{
- var model = tf.keras.Sequential();
- model.add(tf.keras.Input(shape: 16));
+ var model = keras.Sequential();
+ model.add(keras.Input(shape: 16));
}
[TestMethod]
@@ -30,10 +26,10 @@ namespace TensorFlowNET.UnitTest.Keras
var inputs = keras.Input(shape: 784);
Assert.AreEqual((None, 784), inputs.TensorShape);
- var dense = layers.Dense(64, activation: tf.keras.activations.Relu);
+ var dense = layers.Dense(64, activation: keras.activations.Relu);
var x = dense.Apply(inputs);
- x = layers.Dense(64, activation: tf.keras.activations.Relu).Apply(x);
+ x = layers.Dense(64, activation: keras.activations.Relu).Apply(x);
var outputs = layers.Dense(10).Apply(x);
var model = keras.Model(inputs, outputs, name: "mnist_model");
@@ -46,8 +42,8 @@ namespace TensorFlowNET.UnitTest.Keras
[TestMethod, Ignore]
public void Embedding()
{
- var model = tf.keras.Sequential();
- var layer = tf.keras.layers.Embedding(7, 2, input_length: 4);
+ var model = keras.Sequential();
+ var layer = keras.layers.Embedding(7, 2, input_length: 4);
model.add(layer);
// the model will take as input an integer matrix of size (batch,
// input_length).
@@ -73,14 +69,14 @@ namespace TensorFlowNET.UnitTest.Keras
public void Dense()
{
// Create a `Sequential` model and add a Dense layer as the first layer.
- var model = tf.keras.Sequential();
- model.add(tf.keras.Input(shape: 16));
- model.add(tf.keras.layers.Dense(32, activation: tf.keras.activations.Relu));
+ var model = keras.Sequential();
+ model.add(keras.Input(shape: 16));
+ model.add(keras.layers.Dense(32, activation: keras.activations.Relu));
// Now the model will take as input arrays of shape (None, 16)
// and output arrays of shape (None, 32).
// Note that after the first layer, you don't need to specify
// the size of the input anymore:
- model.add(tf.keras.layers.Dense(32));
+ model.add(keras.layers.Dense(32));
Assert.AreEqual((-1, 32), model.output_shape);
}
diff --git a/test/TensorFlowNET.UnitTest/Keras/ModelSaveTest.cs b/test/TensorFlowNET.UnitTest/Keras/ModelSaveTest.cs
index 40d0e22b..86f87f32 100644
--- a/test/TensorFlowNET.UnitTest/Keras/ModelSaveTest.cs
+++ b/test/TensorFlowNET.UnitTest/Keras/ModelSaveTest.cs
@@ -3,10 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Keras.Engine;
-using Tensorflow.Keras.Layers;
-using NumSharp;
-using Tensorflow.UnitTest;
-using static Tensorflow.Binding;
+using static Tensorflow.KerasExt;
namespace TensorFlowNET.UnitTest.Keras
{
@@ -24,8 +21,6 @@ namespace TensorFlowNET.UnitTest.Keras
Model GetModel()
{
- var keras = tf.keras;
-
// Create a simple model.
var inputs = keras.Input(shape: 32);
var dense_layer = keras.layers.Dense(1);
diff --git a/test/TensorFlowNET.UnitTest/Tensorflow.UnitTest.csproj b/test/TensorFlowNET.UnitTest/Tensorflow.UnitTest.csproj
index 42e28129..68b70eb4 100644
--- a/test/TensorFlowNET.UnitTest/Tensorflow.UnitTest.csproj
+++ b/test/TensorFlowNET.UnitTest/Tensorflow.UnitTest.csproj
@@ -55,7 +55,7 @@
-
+