Skip to content

Commit e16ecdf

Browse files
Base Layer class sketonizing
1 parent b9c339c commit e16ecdf

11 files changed

Lines changed: 65 additions & 34 deletions

File tree

src/TensorFlowNET.Keras/Constraints/ConstraintBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tensorflow.Keras.Constraints
66
{
7-
class ConstraintBase
7+
public abstract class ConstraintBase
88
{
99
}
1010
}

src/TensorFlowNET.Keras/Engine/BaseLayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tensorflow.Keras.Engine
66
{
7-
class BaseLayer
7+
public class Layer
88
{
99
}
1010
}
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
using Tensorflow.Keras.Initializers;
5+
using Tensorflow.Keras.Metrics;
46

57
namespace Tensorflow.Keras.Engine
68
{
7-
class BaseLayerUtils
9+
public class BaseLayerUtils
810
{
11+
public static (Metric, Metric) create_mean_metric(Tensor value, string name = null) => throw new NotImplementedException();
12+
13+
public static VariableV1 make_variable(string name, TensorShape shape= null, TF_DataType dtype= TF_DataType.TF_FLOAT, Initializer initializer= null,
14+
bool trainable= true, string caching_device= null, bool validate_shape= true, Constraints.ConstraintBase constraint= null,
15+
bool use_resource= false, Graph[] collections= null, VariableSynchronization synchronization= VariableSynchronization.Auto,
16+
VariableAggregation aggregation= VariableAggregation.None) => throw new NotImplementedException();
17+
18+
public static Tensor[] collect_previous_mask(TensorArray input_tensors) => throw new NotImplementedException();
19+
20+
public bool have_all_keras_metadata(Tensor[] tensors) => throw new NotImplementedException();
21+
22+
public static dynamic generate_placeholders_from_shape(TensorShape shape) => throw new NotImplementedException();
923
}
1024
}

src/TensorFlowNET.Keras/Initializer/BaseInitializer.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/TensorFlowNET.Keras/Initializers/Initializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tensorflow.Keras.Initializers
66
{
7-
class Initializer
7+
public abstract class Initializer
88
{
99
}
1010
}

src/TensorFlowNET.Keras/Layers/Core/Dense.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ limitations under the License.
2323

2424
namespace Keras.Layers
2525
{
26-
public class Dense : ILayer
26+
public class Dense : Layer
2727
{
2828
RefVariable W;
2929
int units;
@@ -37,7 +37,7 @@ public Dense(int units, string name = null, IActivation activation = null)
3737
this.units = units;
3838
this.name = (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))?this.GetType().Name + "_" + this.GetType().GUID:name;
3939
}
40-
public ILayer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f)
40+
public Layer __build__(TensorShape input_shape, int seed = 1, float stddev = -1f)
4141
{
4242
Console.WriteLine("Building Layer \"" + name + "\" ...");
4343
if (stddev == -1)

src/TensorFlowNET.Keras/Layers/ILayer.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Tensorflow;
4+
using Tensorflow.Keras.Constraints;
5+
using Tensorflow.Keras.Initializers;
6+
using Tensorflow.Keras.Regularizers;
7+
8+
namespace Keras.Layers
9+
{
10+
public abstract class Layer
11+
{
12+
public Layer(bool trainable = true, string name = null, string dtype = null, bool @dynamic = false, Dictionary<string, object> kwargs = null)
13+
{
14+
15+
}
16+
17+
public void build(TensorShape shape) => throw new NotImplementedException();
18+
19+
public void call(Tensor[] inputs) => throw new NotImplementedException();
20+
21+
public void _add_trackable(dynamic trackable_object, bool trainable) => throw new NotImplementedException();
22+
23+
public void add_weight(string name= null, TensorShape shape= null, string dtype= null, Initializer initializer = null,
24+
Regularizer regularizer = null, bool? trainable = null, ConstraintBase constraint = null,
25+
dynamic partitioner= null, bool? use_resource= null, VariableSynchronization synchronization= VariableSynchronization.Auto,
26+
VariableAggregation aggregation= VariableAggregation.None, Dictionary<string, object> kwargs = null) => throw new NotImplementedException();
27+
28+
public Dictionary<string, object> get_config() => throw new NotImplementedException();
29+
30+
public Layer from_config(Dictionary<string, object> config) => throw new NotImplementedException();
31+
32+
public TensorShape compute_output_shape(TensorShape input_shape) => throw new NotImplementedException();
33+
34+
public dynamic compute_output_signature(dynamic input_signature) => throw new NotImplementedException();
35+
}
36+
}

src/TensorFlowNET.Keras/Metrics/Metric.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tensorflow.Keras.Metrics
66
{
7-
class Metric
7+
public abstract class Metric
88
{
99
}
1010
}

src/TensorFlowNET.Keras/Model.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ namespace Tensorflow.Keras
2626
public class Model
2727
{
2828
public Tensor Flow;
29-
List<ILayer> layer_stack;
29+
List<Layer> layer_stack;
3030

3131
public TensorShape InputShape;
3232

3333
public Model()
3434
{
35-
layer_stack = new List<ILayer>();
35+
layer_stack = new List<Layer>();
3636
}
37-
public Model Add(ILayer layer)
37+
public Model Add(Layer layer)
3838
{
3939
layer_stack.Add(layer);
4040
return this;
4141
}
42-
public Model Add(IEnumerable<ILayer> layers)
42+
public Model Add(IEnumerable<Layer> layers)
4343
{
4444
layer_stack.AddRange(layers);
4545
return this;
@@ -83,9 +83,9 @@ public Tensor getFlow()
8383
Flow = features;
8484
for (int i = 0; i < layer_stack.Count; i++)
8585
{
86-
layer_stack[i].__build__(flow_shape);
87-
flow_shape = layer_stack[i].output_shape(flow_shape);
88-
Flow = layer_stack[i].__call__(Flow);
86+
//layer_stack[i].build(flow_shape);
87+
//flow_shape = layer_stack[i].output_shape(flow_shape);
88+
//Flow = layer_stack[i].__call__(Flow);
8989
}
9090
var predictions = tf.sigmoid(tf.squeeze(Flow));
9191

0 commit comments

Comments
 (0)