Browse Source

fix ndarray to tensor implicit convertion.

tags/v0.60-tf.numpy
Oceania2018 4 years ago
parent
commit
083c8e8d6f
2 changed files with 7 additions and 1 deletions
  1. +6
    -0
      src/TensorFlowNET.Core/Binding.Util.cs
  2. +1
    -1
      src/TensorFlowNET.Core/NumPy/NDArray.Implicit.cs

+ 6
- 0
src/TensorFlowNET.Core/Binding.Util.cs View File

@@ -508,6 +508,12 @@ namespace Tensorflow


public static Shape GetShape(this object data) public static Shape GetShape(this object data)
{ {
if (data is NDArray nd)
return nd.shape;

if (data is Tensor tensor)
return tensor.shape;

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




+ 1
- 1
src/TensorFlowNET.Core/NumPy/NDArray.Implicit.cs View File

@@ -37,7 +37,7 @@ namespace Tensorflow.NumPy
=> new NDArray(value); => new NDArray(value);


public static implicit operator Tensor(NDArray nd) public static implicit operator Tensor(NDArray nd)
=> nd._tensor;
=> constant_op.constant(nd);


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


Loading…
Cancel
Save