Browse Source

Base Layer class sketonizing

tags/v0.20
Deepak Battini 5 years ago
parent
commit
e16ecdf04e
11 changed files with 65 additions and 34 deletions
  1. +1
    -1
      src/TensorFlowNET.Keras/Constraints/ConstraintBase.cs
  2. +1
    -1
      src/TensorFlowNET.Keras/Engine/BaseLayer.cs
  3. +15
    -1
      src/TensorFlowNET.Keras/Engine/BaseLayerUtils.cs
  4. +0
    -7
      src/TensorFlowNET.Keras/Initializer/BaseInitializer.cs
  5. +1
    -1
      src/TensorFlowNET.Keras/Initializers/Initializer.cs
  6. +2
    -2
      src/TensorFlowNET.Keras/Layers/Core/Dense.cs
  7. +0
    -12
      src/TensorFlowNET.Keras/Layers/ILayer.cs
  8. +36
    -0
      src/TensorFlowNET.Keras/Layers/Layer.cs
  9. +1
    -1
      src/TensorFlowNET.Keras/Metrics/Metric.cs
  10. +7
    -7
      src/TensorFlowNET.Keras/Model.cs
  11. +1
    -1
      src/TensorFlowNET.Keras/Regularizers/Regularizer.cs

+ 1
- 1
src/TensorFlowNET.Keras/Constraints/ConstraintBase.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.Constraints
{
class ConstraintBase
public abstract class ConstraintBase
{
}
}

+ 1
- 1
src/TensorFlowNET.Keras/Engine/BaseLayer.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.Engine
{
class BaseLayer
public class Layer
{
}
}

+ 15
- 1
src/TensorFlowNET.Keras/Engine/BaseLayerUtils.cs View File

@@ -1,10 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using Tensorflow.Keras.Initializers;
using Tensorflow.Keras.Metrics;

namespace Tensorflow.Keras.Engine
{
class BaseLayerUtils
public class BaseLayerUtils
{
public static (Metric, Metric) create_mean_metric(Tensor value, string name = null) => throw new NotImplementedException();

public static VariableV1 make_variable(string name, TensorShape shape= null, TF_DataType dtype= TF_DataType.TF_FLOAT, Initializer initializer= null,
bool trainable= true, string caching_device= null, bool validate_shape= true, Constraints.ConstraintBase constraint= null,
bool use_resource= false, Graph[] collections= null, VariableSynchronization synchronization= VariableSynchronization.Auto,
VariableAggregation aggregation= VariableAggregation.None) => throw new NotImplementedException();

public static Tensor[] collect_previous_mask(TensorArray input_tensors) => throw new NotImplementedException();

public bool have_all_keras_metadata(Tensor[] tensors) => throw new NotImplementedException();

public static dynamic generate_placeholders_from_shape(TensorShape shape) => throw new NotImplementedException();
}
}

+ 0
- 7
src/TensorFlowNET.Keras/Initializer/BaseInitializer.cs View File

@@ -1,7 +0,0 @@
namespace Keras.Initializer
{
class BaseInitializer : IInitializer
{
public int seed;
}
}

+ 1
- 1
src/TensorFlowNET.Keras/Initializers/Initializer.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.Initializers
{
class Initializer
public abstract class Initializer
{
}
}

+ 2
- 2
src/TensorFlowNET.Keras/Layers/Core/Dense.cs View File

@@ -23,7 +23,7 @@ using static Tensorflow.Binding;

namespace Keras.Layers
{
public class Dense : ILayer
public class Dense : Layer
{
RefVariable W;
int units;
@@ -37,7 +37,7 @@ namespace Keras.Layers
this.units = units;
this.name = (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))?this.GetType().Name + "_" + this.GetType().GUID:name;
}
public ILayer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f)
public Layer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f)
{
Console.WriteLine("Building Layer \"" + name + "\" ...");
if (stddev == -1)


+ 0
- 12
src/TensorFlowNET.Keras/Layers/ILayer.cs View File

@@ -1,12 +0,0 @@
using Tensorflow;

namespace Keras.Layers
{
public interface ILayer
{
TensorShape __shape__();
ILayer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f);
Tensor __call__(Tensor x);
TensorShape output_shape(TensorShape input_shape);
}
}

+ 36
- 0
src/TensorFlowNET.Keras/Layers/Layer.cs View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using Tensorflow;
using Tensorflow.Keras.Constraints;
using Tensorflow.Keras.Initializers;
using Tensorflow.Keras.Regularizers;

namespace Keras.Layers
{
public abstract class Layer
{
public Layer(bool trainable = true, string name = null, string dtype = null, bool @dynamic = false, Dictionary<string, object> kwargs = null)
{

}

public void build(TensorShape shape) => throw new NotImplementedException();

public 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<string, object> kwargs = null) => throw new NotImplementedException();

public Dictionary<string, object> get_config() => throw new NotImplementedException();

public Layer from_config(Dictionary<string, object> 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();
}
}

+ 1
- 1
src/TensorFlowNET.Keras/Metrics/Metric.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.Metrics
{
class Metric
public abstract class Metric
{
}
}

+ 7
- 7
src/TensorFlowNET.Keras/Model.cs View File

@@ -26,20 +26,20 @@ namespace Tensorflow.Keras
public class Model
{
public Tensor Flow;
List<ILayer> layer_stack;
List<Layer> layer_stack;

public TensorShape InputShape;

public Model()
{
layer_stack = new List<ILayer>();
layer_stack = new List<Layer>();
}
public Model Add(ILayer layer)
public Model Add(Layer layer)
{
layer_stack.Add(layer);
return this;
}
public Model Add(IEnumerable<ILayer> layers)
public Model Add(IEnumerable<Layer> layers)
{
layer_stack.AddRange(layers);
return this;
@@ -83,9 +83,9 @@ namespace Tensorflow.Keras
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);
//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));


+ 1
- 1
src/TensorFlowNET.Keras/Regularizers/Regularizer.cs View File

@@ -4,7 +4,7 @@ using System.Text;

namespace Tensorflow.Keras.Regularizers
{
class Regularizer
public class Regularizer
{
}
}

Loading…
Cancel
Save