Skip to content

Commit b209fac

Browse files
committed
TensorShape of variable. #138
1 parent a0de3a0 commit b209fac

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/TensorFlowNET.Core/Tensors/tensor_util.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public static TensorShapeProto as_shape(long[] dims)
8989
return shape;
9090
}
9191

92+
public static TensorShape to_shape(long[] dims)
93+
{
94+
return new TensorShape(dims.Select(x => (int)x).ToArray());
95+
}
96+
9297
public static TensorShape as_shape(this IShape shape, int[] dims)
9398
{
9499
return new TensorShape(dims);

src/TensorFlowNET.Core/Variables/RefVariable.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public partial class RefVariable : VariableV1
1818
public Operation initializer => _initializer_op;
1919
public Operation op => _variable.op;
2020
public TF_DataType dtype => _variable.dtype;
21+
public TensorShape shape => tensor_util.to_shape(_variable.shape);
2122

2223
public string name => _variable.name;
2324

0 commit comments

Comments
 (0)