@@ -4,7 +4,7 @@ using System.Text; | |||||
namespace Tensorflow.Keras.Constraints | namespace Tensorflow.Keras.Constraints | ||||
{ | { | ||||
class ConstraintBase | |||||
public abstract class ConstraintBase | |||||
{ | { | ||||
} | } | ||||
} | } |
@@ -4,7 +4,7 @@ using System.Text; | |||||
namespace Tensorflow.Keras.Engine | namespace Tensorflow.Keras.Engine | ||||
{ | { | ||||
class BaseLayer | |||||
public class Layer | |||||
{ | { | ||||
} | } | ||||
} | } |
@@ -1,10 +1,24 @@ | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Text; | using System.Text; | ||||
using Tensorflow.Keras.Initializers; | |||||
using Tensorflow.Keras.Metrics; | |||||
namespace Tensorflow.Keras.Engine | 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(); | |||||
} | } | ||||
} | } |
@@ -1,7 +0,0 @@ | |||||
namespace Keras.Initializer | |||||
{ | |||||
class BaseInitializer : IInitializer | |||||
{ | |||||
public int seed; | |||||
} | |||||
} |
@@ -4,7 +4,7 @@ using System.Text; | |||||
namespace Tensorflow.Keras.Initializers | namespace Tensorflow.Keras.Initializers | ||||
{ | { | ||||
class Initializer | |||||
public abstract class Initializer | |||||
{ | { | ||||
} | } | ||||
} | } |
@@ -23,7 +23,7 @@ using static Tensorflow.Binding; | |||||
namespace Keras.Layers | namespace Keras.Layers | ||||
{ | { | ||||
public class Dense : ILayer | |||||
public class Dense : Layer | |||||
{ | { | ||||
RefVariable W; | RefVariable W; | ||||
int units; | int units; | ||||
@@ -37,7 +37,7 @@ namespace Keras.Layers | |||||
this.units = units; | this.units = units; | ||||
this.name = (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))?this.GetType().Name + "_" + this.GetType().GUID:name; | 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 + "\" ..."); | Console.WriteLine("Building Layer \"" + name + "\" ..."); | ||||
if (stddev == -1) | if (stddev == -1) | ||||
@@ -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); | |||||
} | |||||
} |
@@ -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(); | |||||
} | |||||
} |
@@ -4,7 +4,7 @@ using System.Text; | |||||
namespace Tensorflow.Keras.Metrics | namespace Tensorflow.Keras.Metrics | ||||
{ | { | ||||
class Metric | |||||
public abstract class Metric | |||||
{ | { | ||||
} | } | ||||
} | } |
@@ -26,20 +26,20 @@ namespace Tensorflow.Keras | |||||
public class Model | public class Model | ||||
{ | { | ||||
public Tensor Flow; | public Tensor Flow; | ||||
List<ILayer> layer_stack; | |||||
List<Layer> layer_stack; | |||||
public TensorShape InputShape; | public TensorShape InputShape; | ||||
public Model() | 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); | layer_stack.Add(layer); | ||||
return this; | return this; | ||||
} | } | ||||
public Model Add(IEnumerable<ILayer> layers) | |||||
public Model Add(IEnumerable<Layer> layers) | |||||
{ | { | ||||
layer_stack.AddRange(layers); | layer_stack.AddRange(layers); | ||||
return this; | return this; | ||||
@@ -83,9 +83,9 @@ namespace Tensorflow.Keras | |||||
Flow = features; | Flow = features; | ||||
for (int i = 0; i < layer_stack.Count; i++) | 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)); | var predictions = tf.sigmoid(tf.squeeze(Flow)); | ||||
@@ -4,7 +4,7 @@ using System.Text; | |||||
namespace Tensorflow.Keras.Regularizers | namespace Tensorflow.Keras.Regularizers | ||||
{ | { | ||||
class Regularizer | |||||
public class Regularizer | |||||
{ | { | ||||
} | } | ||||
} | } |