From b962e6ff118fd9787b8165fa6dfcb2f7aa230edc Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Thu, 1 Aug 2019 17:55:07 -0500 Subject: [PATCH] MakeNdarray exception when shape is empty. --- src/TensorFlowNET.Core/Tensors/tensor_util.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TensorFlowNET.Core/Tensors/tensor_util.cs b/src/TensorFlowNET.Core/Tensors/tensor_util.cs index f7089a8e..2487e9d9 100644 --- a/src/TensorFlowNET.Core/Tensors/tensor_util.cs +++ b/src/TensorFlowNET.Core/Tensors/tensor_util.cs @@ -57,7 +57,7 @@ namespace Tensorflow public static NDArray MakeNdarray(TensorProto tensor) { var shape = tensor.TensorShape.Dim.Select(x => (int)x.Size).ToArray(); - int num_elements = np.prod(shape); + int num_elements = shape.Length == 0 ? NDArray.Scalar(1) : np.prod(shape); var tensor_dtype = tensor.Dtype.as_numpy_dtype(); if (tensor.TensorContent.Length > 0)