Skip to content

Commit 083c8e8

Browse files
committed
fix ndarray to tensor implicit convertion.
1 parent efb1c24 commit 083c8e8

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/TensorFlowNET.Core/Binding.Util.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ public static TValue Get<TKey, TValue>(this Dictionary<TKey, TValue> dic, TKey k
508508

509509
public static Shape GetShape(this object data)
510510
{
511+
if (data is NDArray nd)
512+
return nd.shape;
513+
514+
if (data is Tensor tensor)
515+
return tensor.shape;
516+
511517
if (!data.GetType().IsArray)
512518
return Shape.Scalar;
513519

‎src/TensorFlowNET.Core/NumPy/NDArray.Implicit.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static implicit operator NDArray(double value)
3737
=> new NDArray(value);
3838

3939
public static implicit operator Tensor(NDArray nd)
40-
=> nd._tensor;
40+
=> constant_op.constant(nd);
4141

4242
public static implicit operator NDArray(Tensor tensor)
4343
=> new NDArray(tensor);

0 commit comments

Comments
 (0)