Skip to content

Commit f980266

Browse files
committed
fix GetShape for Axis.
1 parent 141bdf3 commit f980266

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/TensorFlowNET.Core/Binding.Util.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public static Shape GetShape(this object data)
517517
return tensor.shape;
518518

519519
else if (data is Axis axis)
520-
return axis.IsScalar ? Shape.Scalar : new Shape(axis.axis);
520+
return axis.IsScalar ? Shape.Scalar : new Shape(axis.axis.Length);
521521

522522
else if (!data.GetType().IsArray)
523523
return Shape.Scalar;

src/TensorFlowNET.Keras/Utils/np_utils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static NDArray to_categorical(NDArray y, int num_classes = -1, TF_DataTyp
2020
// var input_shape = y.shape[..^1];
2121
var categorical = np.zeros(((int)y.size, num_classes), dtype: dtype);
2222
// categorical[np.arange(y.size), y] = 1;
23-
for (ulong i = 0; i < y.size; i++)
23+
for (var i = 0; i < (int)y.size; i++)
2424
{
25-
categorical[i][y1[i]] = 1;
25+
categorical[i][y1[i]] = 1.0f;
2626
}
2727

2828
return categorical;

0 commit comments

Comments
 (0)