FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

1st stage to integrate with NumSharp. · MSavameri/TensorFlow.NET@20b348c · GitHub

Repository navigation

Commit 20b348c

Browse files
committed
1st stage to integrate with NumSharp.
1 parent ca99be3 commit 20b348c

34 files changed

Lines changed: 123 additions & 103 deletions

‎TensorFlow.NET.sln‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowBenchmark", "src\
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowHub", "src\TensorFlowHub\TensorFlowHub.csproj", "{8FD59A5A-97EB-457E-B9F1-D88B0C822C6E}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowText", "src\TensorFlowText\TensorFlowText.csproj", "{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}"
21+
EndProject
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NumSharp.Core", "..\NumSharp\src\NumSharp.Core\NumSharp.Core.csproj", "{F219B9B9-B873-4342-BF85-7E89E7F5D64F}"
2123
EndProject
2224
Global
2325
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -57,6 +59,10 @@ Global
5759
{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Debug|Any CPU.Build.0 = Debug|Any CPU
5860
{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.ActiveCfg = Release|Any CPU
5961
{B598E5D5-BD2D-4191-8532-F2FBAC31AB81}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{F219B9B9-B873-4342-BF85-7E89E7F5D64F}.Release|Any CPU.Build.0 = Release|Any CPU
6066
EndGlobalSection
6167
GlobalSection(SolutionProperties) = preSolution
6268
HideSolutionNode = FALSE

‎src/KerasNET.Core/Layers/Dense.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ILayer __build__(TensorShape input_shape, int seed = 1, float stddev = -1
4141
Console.WriteLine("Building Layer \"" + name + "\" ...");
4242
if (stddev == -1)
4343
stddev = (float)(1 / Math.Sqrt(2));
44-
var dim = input_shape.Dimensions;
44+
var dim = input_shape.dims;
4545
var input_dim = dim[dim.Length - 1];
4646
W = tf.Variable(create_tensor(new int[] { input_dim, units }, seed: seed, stddev: (float)stddev));
4747
WShape = new TensorShape(W.shape);
@@ -52,7 +52,7 @@ public Tensor __call__(Tensor x)
5252
var dot = tf.matmul(x, W);
5353
if (this.activation != null)
5454
dot = activation.Activate(dot);
55-
Console.WriteLine("Calling Layer \"" + name + "(" + np.array(dot.TensorShape.Dimensions).ToString() + ")\" ...");
55+
Console.WriteLine("Calling Layer \"" + name + "(" + np.array(dot.TensorShape.dims).ToString() + ")\" ...");
5656
return dot;
5757
}
5858
public TensorShape __shape__()
@@ -61,7 +61,7 @@ public TensorShape __shape__()
6161
}
6262
public TensorShape output_shape(TensorShape input_shape)
6363
{
64-
var output_shape = input_shape.Dimensions;
64+
var output_shape = input_shape.dims;
6565
output_shape[output_shape.Length - 1] = units;
6666
return new TensorShape(output_shape);
6767
}

‎src/TensorFlowNET.Core/Contrib/Learn/Estimators/tensor_signature.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public static bool is_compatible_with(this Tensor self, Tensor other)
1111
bool _shape_is_compatible_0dim(Shape _this, Shape _other)
1212
{
1313
var __other = tensor_shape.as_shape(_other);
14-
if (_this.Dimensions == null || __other.Dimensions == null)
14+
if (_this.Dimensions == null || __other.dims == null)
1515
return true;
1616

17-
if (_this.NDim != __other.NDim)
17+
if (_this.NDim != __other.ndim)
1818
return false;
1919

20-
foreach (var (x_dim, y_dim) in _this.Dimensions.Zip(__other.Dimensions, (x_dim, y_dim) => (x_dim, y_dim)))
20+
foreach (var (x_dim, y_dim) in _this.Dimensions.Zip(__other.dims, (x_dim, y_dim) => (x_dim, y_dim)))
2121
{
2222
if (x_dim != y_dim)
2323
return false;

‎src/TensorFlowNET.Core/Framework/tensor_shape.cs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ public static void assert_is_compatible_with(this Tensor self, Tensor other)
2525
}
2626

2727
public static TensorShape as_shape(this Shape shape)
28-
{
29-
if (shape is TensorShape tshape)
30-
return tshape;
31-
return new TensorShape(shape);
32-
}
28+
=> new TensorShape(shape.Dimensions);
3329
}
3430
}

‎src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public BatchNormalization(int axis = -1,
8181

8282
protected override void build(TensorShape input_shape)
8383
{
84-
var ndims = input_shape.NDim;
84+
var ndims = input_shape.ndim;
8585
foreach (var (idx, x) in Python.enumerate(axis))
8686
if (x < 0)
8787
axis[idx] = ndims + x;
@@ -91,7 +91,7 @@ protected override void build(TensorShape input_shape)
9191
_data_format = "NHWC";
9292

9393
var param_dtype = _dtype == TF_DataType.DtInvalid ? TF_DataType.TF_FLOAT : _dtype;
94-
var param_shape = new int[] { input_shape.Dimensions[axis[0]] };
94+
var param_shape = new int[] { input_shape.dims[axis[0]] };
9595

9696
if (scale)
9797
gamma = add_weight("gamma",

‎src/TensorFlowNET.Core/Keras/Layers/Conv.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ protected override void build(TensorShape input_shape)
7272
{
7373
int channel_axis = data_format == "channels_first" ? 1 : -1;
7474
int input_dim = channel_axis < 0 ?
75-
input_shape.Dimensions[input_shape.NDim + channel_axis] :
76-
input_shape.Dimensions[channel_axis];
75+
input_shape.dims[input_shape.ndim + channel_axis] :
76+
input_shape.dims[channel_axis];
7777
var kernel_shape = new int[] { kernel_size[0], kernel_size[1], input_dim, filters };
7878
kernel = add_weight(name: "kernel",
7979
shape: kernel_shape,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Dense(int units,
5151

5252
protected override void build(TensorShape input_shape)
5353
{
54-
var last_dim = input_shape.Dimensions.Last();
54+
var last_dim = input_shape.dims.Last();
5555
var axes = new Dictionary<int, int>();
5656
axes[-1] = last_dim;
5757
input_spec = new InputSpec(min_ndim: 2, axes: axes);

‎src/TensorFlowNET.Core/Operations/Initializers/Ones.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public Tensor call(TensorShape shape, TF_DataType dtype = TF_DataType.DtInvalid)
3030
if (dtype == TF_DataType.DtInvalid)
3131
dtype = this.dtype;
3232

33-
return array_ops.ones(shape.Dimensions, dtype);
33+
return array_ops.ones(shape.dims, dtype);
3434
}
3535

3636
public object get_config()

‎src/TensorFlowNET.Core/Operations/Losses/losses_impl.py.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public Tensor sparse_softmax_cross_entropy(Tensor labels,
132132
if(weights > 0)
133133
{
134134
var weights_tensor = ops.convert_to_tensor(weights);
135-
var labels_rank = labels.TensorShape.NDim;
135+
var labels_rank = labels.TensorShape.ndim;
136136
var weights_shape = weights_tensor.TensorShape;
137-
var weights_rank = weights_shape.NDim;
137+
var weights_rank = weights_shape.ndim;
138138

139139
if (labels_rank > -1 && weights_rank > -1)
140140
{

‎src/TensorFlowNET.Core/Operations/NnOps/Convolution.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ public Convolution(TensorShape input_shape,
3535
string name = null,
3636
string data_format = null)
3737
{
38-
var num_total_dims = filter_shape.NDim;
38+
var num_total_dims = filter_shape.ndim;
3939
var num_spatial_dims = num_total_dims - 2;
4040
int input_channels_dim;
4141
int[] spatial_dims;
4242
if (string.IsNullOrEmpty(data_format) || !data_format.StartsWith("NC"))
4343
{
44-
input_channels_dim = input_shape.Dimensions[num_spatial_dims + 1];
44+
input_channels_dim = input_shape.dims[num_spatial_dims + 1];
4545
spatial_dims = Enumerable.Range(1, num_spatial_dims).ToArray();
4646
}
4747
else
4848
{
49-
input_channels_dim = input_shape.Dimensions[1];
49+
input_channels_dim = input_shape.dims[1];
5050
spatial_dims = Enumerable.Range(2, num_spatial_dims).ToArray();
5151
}
5252

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL