Browse Source

TensorShape: fixed size computation when None is used.

tags/v0.12
Eli Belash 6 years ago
parent
commit
4db89af049
1 changed files with 17 additions and 1 deletions
  1. +17
    -1
      src/TensorFlowNET.Core/Tensors/TensorShape.cs

+ 17
- 1
src/TensorFlowNET.Core/Tensors/TensorShape.cs View File

@@ -33,7 +33,23 @@ namespace Tensorflow
/// <summary>
/// Returns the size this shape represents.
/// </summary>
public int size => shape.Size;
public int size
{
get
{
var dims = shape.Dimensions;
var computed = 1;
for (int i = 0; i < dims.Length; i++)
{
var val = dims[i];
if (val <= 0)
continue;
computed *= val;
}

return computed;
}
}

public TensorShape(TensorShapeProto proto)
{


Loading…
Cancel
Save