diff --git a/src/TensorFlowNET.Console/MemoryBasicTest.cs b/src/TensorFlowNET.Console/MemoryBasicTest.cs
index f1e5e20a..15278084 100644
--- a/src/TensorFlowNET.Console/MemoryBasicTest.cs
+++ b/src/TensorFlowNET.Console/MemoryBasicTest.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine.DataAdapters;
diff --git a/src/TensorFlowNET.Console/MemoryFuncGraphTest.cs b/src/TensorFlowNET.Console/MemoryFuncGraphTest.cs
index 8c39cf7a..c43d0a2b 100644
--- a/src/TensorFlowNET.Console/MemoryFuncGraphTest.cs
+++ b/src/TensorFlowNET.Console/MemoryFuncGraphTest.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/TensorFlowNET.Console/MemoryKerasTest.cs b/src/TensorFlowNET.Console/MemoryKerasTest.cs
index a58a2a34..98d20356 100644
--- a/src/TensorFlowNET.Console/MemoryKerasTest.cs
+++ b/src/TensorFlowNET.Console/MemoryKerasTest.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using static Tensorflow.Binding;
using static Tensorflow.KerasApi;
diff --git a/src/TensorFlowNET.Console/MemoryMonitor.cs b/src/TensorFlowNET.Console/MemoryMonitor.cs
index 80c64e70..8916cac6 100644
--- a/src/TensorFlowNET.Console/MemoryMonitor.cs
+++ b/src/TensorFlowNET.Console/MemoryMonitor.cs
@@ -2,7 +2,7 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using static Tensorflow.Binding;
using static Tensorflow.KerasApi;
diff --git a/src/TensorFlowNET.Core/APIs/tf.array.cs b/src/TensorFlowNET.Core/APIs/tf.array.cs
index 5a103598..2bc856c8 100644
--- a/src/TensorFlowNET.Core/APIs/tf.array.cs
+++ b/src/TensorFlowNET.Core/APIs/tf.array.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
diff --git a/src/TensorFlowNET.Core/APIs/tf.numpy.cs b/src/TensorFlowNET.Core/APIs/tf.numpy.cs
new file mode 100644
index 00000000..392ba915
--- /dev/null
+++ b/src/TensorFlowNET.Core/APIs/tf.numpy.cs
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ Copyright 2021 Haiping Chen. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+******************************************************************************/
+
+using Tensorflow.NumPy;
+
+namespace Tensorflow
+{
+ public partial class tensorflow
+ {
+ ///
+ /// NumPy API on TensorFlow
+ /// https://www.tensorflow.org/api_docs/python/tf/experimental/numpy
+ ///
+ public NumPyImpl numpy => new NumPyImpl();
+ }
+}
diff --git a/src/TensorFlowNET.Core/Binding.Util.cs b/src/TensorFlowNET.Core/Binding.Util.cs
index 7b6c1c35..e6069023 100644
--- a/src/TensorFlowNET.Core/Binding.Util.cs
+++ b/src/TensorFlowNET.Core/Binding.Util.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -174,6 +174,9 @@ namespace Tensorflow
throw new NotImplementedException("len() not implemented for type: " + a.GetType());
}
+ public static int min(int a, int b)
+ => Math.Min(a, b);
+
public static float min(float a, float b)
=> Math.Min(a, b);
diff --git a/src/TensorFlowNET.Core/Data/DataSetBase.cs b/src/TensorFlowNET.Core/Data/DataSetBase.cs
index aac28a88..2face8bc 100644
--- a/src/TensorFlowNET.Core/Data/DataSetBase.cs
+++ b/src/TensorFlowNET.Core/Data/DataSetBase.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Data/DatasetManager.cs b/src/TensorFlowNET.Core/Data/DatasetManager.cs
index 236d143d..a038a533 100644
--- a/src/TensorFlowNET.Core/Data/DatasetManager.cs
+++ b/src/TensorFlowNET.Core/Data/DatasetManager.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Collections.Generic;
using Tensorflow.Data;
diff --git a/src/TensorFlowNET.Core/Data/Datasets.cs b/src/TensorFlowNET.Core/Data/Datasets.cs
index 16376c11..6a4bb1ca 100644
--- a/src/TensorFlowNET.Core/Data/Datasets.cs
+++ b/src/TensorFlowNET.Core/Data/Datasets.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Data/IDataSet.cs b/src/TensorFlowNET.Core/Data/IDataSet.cs
index 75a13e6f..0ac6ee99 100644
--- a/src/TensorFlowNET.Core/Data/IDataSet.cs
+++ b/src/TensorFlowNET.Core/Data/IDataSet.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Data/MnistDataSet.cs b/src/TensorFlowNET.Core/Data/MnistDataSet.cs
index a2d56245..cc4bd369 100644
--- a/src/TensorFlowNET.Core/Data/MnistDataSet.cs
+++ b/src/TensorFlowNET.Core/Data/MnistDataSet.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Diagnostics;
diff --git a/src/TensorFlowNET.Core/Data/MnistModelLoader.cs b/src/TensorFlowNET.Core/Data/MnistModelLoader.cs
index 0a5b4e70..6018d429 100644
--- a/src/TensorFlowNET.Core/Data/MnistModelLoader.cs
+++ b/src/TensorFlowNET.Core/Data/MnistModelLoader.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.IO;
using System.Threading.Tasks;
diff --git a/src/TensorFlowNET.Core/Data/TensorDataset.cs b/src/TensorFlowNET.Core/Data/TensorDataset.cs
index d9bca060..0ac2eeaa 100644
--- a/src/TensorFlowNET.Core/Data/TensorDataset.cs
+++ b/src/TensorFlowNET.Core/Data/TensorDataset.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;
diff --git a/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs b/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs
index 41791f6e..f9d6ea74 100644
--- a/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs
+++ b/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;
diff --git a/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs b/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
index b2d0bd85..e5af070f 100644
--- a/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
+++ b/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using static Tensorflow.Binding;
diff --git a/src/TensorFlowNET.Core/Framework/graph_util_impl.cs b/src/TensorFlowNET.Core/Framework/graph_util_impl.cs
index a3f2c643..fc25c698 100644
--- a/src/TensorFlowNET.Core/Framework/graph_util_impl.cs
+++ b/src/TensorFlowNET.Core/Framework/graph_util_impl.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Core/Framework/tensor_shape.cs b/src/TensorFlowNET.Core/Framework/tensor_shape.cs
index e0e351d4..73cd7daf 100644
--- a/src/TensorFlowNET.Core/Framework/tensor_shape.cs
+++ b/src/TensorFlowNET.Core/Framework/tensor_shape.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using System.Text;
diff --git a/src/TensorFlowNET.Core/Gradients/array_grad.cs b/src/TensorFlowNET.Core/Gradients/array_grad.cs
index b6ee5f41..f80f8ac6 100644
--- a/src/TensorFlowNET.Core/Gradients/array_grad.cs
+++ b/src/TensorFlowNET.Core/Gradients/array_grad.cs
@@ -18,7 +18,7 @@ using System.Collections.Generic;
using System.Linq;
using Tensorflow.Eager;
using Tensorflow.Framework;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using static Tensorflow.Binding;
namespace Tensorflow.Gradients
diff --git a/src/TensorFlowNET.Core/Gradients/math_grad.cs b/src/TensorFlowNET.Core/Gradients/math_grad.cs
index 96ee41df..34710f70 100644
--- a/src/TensorFlowNET.Core/Gradients/math_grad.cs
+++ b/src/TensorFlowNET.Core/Gradients/math_grad.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using Tensorflow.Eager;
diff --git a/src/TensorFlowNET.Core/Interfaces/ITensorOrOperation.cs b/src/TensorFlowNET.Core/Interfaces/ITensorOrOperation.cs
index 1bdd0021..9fc3be9f 100644
--- a/src/TensorFlowNET.Core/Interfaces/ITensorOrOperation.cs
+++ b/src/TensorFlowNET.Core/Interfaces/ITensorOrOperation.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/Reshaping/ZeroPadding2DArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/Reshaping/ZeroPadding2DArgs.cs
index b3c510b3..ed6e7cc9 100644
--- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/Reshaping/ZeroPadding2DArgs.cs
+++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/Reshaping/ZeroPadding2DArgs.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow.Keras.ArgsDefinition
{
diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs
index 9c165af5..c2981fcc 100644
--- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs
+++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Collections.Generic;
namespace Tensorflow.Keras.ArgsDefinition
diff --git a/src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.Creation.cs b/src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.Creation.cs
new file mode 100644
index 00000000..8e73325c
--- /dev/null
+++ b/src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.Creation.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using static Tensorflow.Binding;
+
+namespace Tensorflow.NumPy
+{
+ public partial class NumPyImpl
+ {
+ public NDArray eye(int N, int? M = null, int k = 0, NumpyDType dtype = NumpyDType.Double)
+ {
+ if (!M.HasValue)
+ M = N;
+
+ var diag_len = min(N, M.Value);
+ if (k > 0)
+ {
+ if (N >= M)
+ diag_len -= k;
+ else if (N + k > M)
+ diag_len = M.Value - k;
+ }
+ else
+ {
+ if (M >= N)
+ diag_len += k;
+ else if (M - k > N)
+ diag_len = N + k;
+ }
+
+ var diagonal_ = array_ops.ones(new TensorShape(diag_len), dtype: dtype.as_tf_dtype());
+ var tensor = array_ops.matrix_diag(diagonal: diagonal_, num_rows: N, num_cols: M.Value, k: k);
+ return new NDArray(tensor);
+ }
+
+ public NDArray linspace(T start, T stop, int num = 50, bool endpoint = true, bool retstep = false,
+ NumpyDType dtype = NumpyDType.Double, int axis = 0)
+ {
+ var start_tensor = array_ops.constant(start, dtype: dtype.as_tf_dtype());
+ var stop_tensor = array_ops.constant(stop, dtype: dtype.as_tf_dtype());
+ var num_tensor = array_ops.constant(num);
+ // var step_tensor = array_ops.constant(np.nan);
+ Tensor result = null;
+
+ if (endpoint)
+ {
+ result = math_ops.linspace(start_tensor, stop_tensor, num_tensor, axis: axis);
+ }
+ else
+ {
+ if (num > 1)
+ {
+ var step = (stop_tensor - start_tensor) / num;
+ var new_stop = math_ops.cast(stop_tensor, step.dtype) - step;
+ start_tensor = math_ops.cast(start_tensor, new_stop.dtype);
+ result = math_ops.linspace(start_tensor, new_stop, num_tensor, axis: axis);
+ }
+ else
+ result = math_ops.linspace(start_tensor, stop_tensor, num_tensor, axis: axis);
+ }
+
+ return new NDArray(result);
+ }
+
+ public (NDArray, NDArray) meshgrid(T[] array, bool copy = true, bool sparse = false)
+ {
+ var tensors = array_ops.meshgrid(array, copy: copy, sparse: sparse);
+ return (new NDArray(tensors[0]), new NDArray(tensors[1]));
+ }
+ }
+}
diff --git a/src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.cs b/src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.cs
new file mode 100644
index 00000000..5c6dee2d
--- /dev/null
+++ b/src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tensorflow.NumPy
+{
+ public partial class NumPyImpl
+ {
+ }
+}
diff --git a/src/TensorFlowNET.Core/Numpy/IMemoryBlock.cs b/src/TensorFlowNET.Core/Numpy/IMemoryBlock.cs
index 2de3c101..9ade984c 100644
--- a/src/TensorFlowNET.Core/Numpy/IMemoryBlock.cs
+++ b/src/TensorFlowNET.Core/Numpy/IMemoryBlock.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public interface IMemoryBlock
{
diff --git a/src/TensorFlowNET.Core/Numpy/InfoOf.cs b/src/TensorFlowNET.Core/Numpy/InfoOf.cs
index 99566eba..feee3a97 100644
--- a/src/TensorFlowNET.Core/Numpy/InfoOf.cs
+++ b/src/TensorFlowNET.Core/Numpy/InfoOf.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public class InfoOf
{
diff --git a/src/TensorFlowNET.Core/Numpy/IteratorType.cs b/src/TensorFlowNET.Core/Numpy/IteratorType.cs
index ab7bee94..ab6345ab 100644
--- a/src/TensorFlowNET.Core/Numpy/IteratorType.cs
+++ b/src/TensorFlowNET.Core/Numpy/IteratorType.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public enum IteratorType
{
diff --git a/src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs b/src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs
index 95443d2c..1ac9fbba 100644
--- a/src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs
+++ b/src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using static Tensorflow.Binding;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public partial class NDArray
{
diff --git a/src/TensorFlowNET.Core/Numpy/NDArray.cs b/src/TensorFlowNET.Core/Numpy/NDArray.cs
index 086b5273..e28591db 100644
--- a/src/TensorFlowNET.Core/Numpy/NDArray.cs
+++ b/src/TensorFlowNET.Core/Numpy/NDArray.cs
@@ -3,12 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public partial class NDArray
{
Tensor _tensor;
-
public NumpyDType dtype => _tensor.dtype.as_numpy_typecode();
public ulong size => _tensor.size;
public ulong dtypesize => _tensor.itemsize;
@@ -166,6 +165,9 @@ namespace Tensorflow.Numpy
public static implicit operator NDArray(float[] value)
=> new NDArray(value);
+ public static implicit operator Tensor(NDArray nd)
+ => nd._tensor;
+
public static NDArray operator /(NDArray x, NDArray y) => throw new NotImplementedException("");
public override string ToString()
diff --git a/src/TensorFlowNET.Core/Numpy/NDIterator.Generic.cs b/src/TensorFlowNET.Core/Numpy/NDIterator.Generic.cs
index b947b72b..2f1a5ff6 100644
--- a/src/TensorFlowNET.Core/Numpy/NDIterator.Generic.cs
+++ b/src/TensorFlowNET.Core/Numpy/NDIterator.Generic.cs
@@ -3,7 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public partial class NDIterator : NDIterator, IEnumerable, IDisposable where TOut : unmanaged
{
diff --git a/src/TensorFlowNET.Core/Numpy/NDIterator.cs b/src/TensorFlowNET.Core/Numpy/NDIterator.cs
index e7fa6105..36862e30 100644
--- a/src/TensorFlowNET.Core/Numpy/NDIterator.cs
+++ b/src/TensorFlowNET.Core/Numpy/NDIterator.cs
@@ -3,7 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public delegate ref T MoveNextReferencedDelegate() where T : unmanaged;
diff --git a/src/TensorFlowNET.Core/Numpy/NpzDictionary.cs b/src/TensorFlowNET.Core/Numpy/NpzDictionary.cs
index 47bc8bf0..9627a629 100644
--- a/src/TensorFlowNET.Core/Numpy/NpzDictionary.cs
+++ b/src/TensorFlowNET.Core/Numpy/NpzDictionary.cs
@@ -6,7 +6,7 @@ using System.IO.Compression;
using System.Linq;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public class NpzDictionary : IDisposable, IReadOnlyDictionary, ICollection
where T : class,
diff --git a/src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs b/src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs
index 3ba878eb..2e8a8021 100644
--- a/src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs
+++ b/src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs
@@ -5,13 +5,10 @@ using System.Numerics;
using System.Text;
using static Tensorflow.Binding;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public partial class np
{
- public static NDArray array(object data)
- => throw new NotImplementedException("");
-
public static NDArray array(Array data)
=> new NDArray(tf.constant(data));
@@ -19,9 +16,6 @@ namespace Tensorflow.Numpy
where T : unmanaged
=> new NDArray(tf.constant(data));
- public static NDArray array(params float[] data)
- => throw new NotImplementedException("");
-
public static NDArray arange(T end)
where T : unmanaged
=> new NDArray(tf.range(default(T), limit: end));
@@ -33,6 +27,19 @@ namespace Tensorflow.Numpy
public static NDArray empty(Shape shape, NumpyDType dtype = NumpyDType.Double)
=> new NDArray(tf.zeros(shape, dtype: dtype.as_tf_dtype()));
+ public static NDArray eye(int N, int? M = null, int k = 0, NumpyDType dtype = NumpyDType.Double)
+ => tf.numpy.eye(N, M: M, k: k, dtype: dtype);
+
+ public static NDArray full(Shape shape, T fill_value)
+ => new NDArray(tf.fill(tf.constant(shape), fill_value));
+
+ public static NDArray linspace(T start, T stop, int num = 50, bool endpoint = true, bool retstep = false,
+ NumpyDType dtype = NumpyDType.Double, int axis = 0) where T : unmanaged
+ => tf.numpy.linspace(start, stop, num: num, endpoint: endpoint, retstep: retstep, dtype: dtype, axis: axis);
+
+ public static (NDArray, NDArray) meshgrid(T x, T y, bool copy = true, bool sparse = false)
+ => tf.numpy.meshgrid(new[] { x, y }, copy: copy, sparse: sparse);
+
public static NDArray ones(Shape shape, NumpyDType dtype = NumpyDType.Double)
=> new NDArray(tf.ones(shape, dtype: dtype.as_tf_dtype()));
@@ -41,8 +48,5 @@ namespace Tensorflow.Numpy
public static NDArray zeros(Shape shape, NumpyDType dtype = NumpyDType.Double)
=> new NDArray(tf.zeros(shape, dtype: dtype.as_tf_dtype()));
-
- public static NDArray full(Shape shape, T fill_value)
- => new NDArray(tf.fill(tf.constant(shape), fill_value));
}
}
diff --git a/src/TensorFlowNET.Core/Numpy/Numpy.cs b/src/TensorFlowNET.Core/Numpy/Numpy.cs
index 20282d8d..d253e805 100644
--- a/src/TensorFlowNET.Core/Numpy/Numpy.cs
+++ b/src/TensorFlowNET.Core/Numpy/Numpy.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public partial class np
{
diff --git a/src/TensorFlowNET.Core/Numpy/NumpyDType.cs b/src/TensorFlowNET.Core/Numpy/NumpyDType.cs
index bfc8dda5..c933d6a8 100644
--- a/src/TensorFlowNET.Core/Numpy/NumpyDType.cs
+++ b/src/TensorFlowNET.Core/Numpy/NumpyDType.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
///
/// Represents all available types in numpy.
diff --git a/src/TensorFlowNET.Core/Numpy/Shape.cs b/src/TensorFlowNET.Core/Numpy/Shape.cs
index aa12a584..7142201c 100644
--- a/src/TensorFlowNET.Core/Numpy/Shape.cs
+++ b/src/TensorFlowNET.Core/Numpy/Shape.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
public class Shape
{
diff --git a/src/TensorFlowNET.Core/Numpy/Slice.cs b/src/TensorFlowNET.Core/Numpy/Slice.cs
index 9dad3059..64d16e47 100644
--- a/src/TensorFlowNET.Core/Numpy/Slice.cs
+++ b/src/TensorFlowNET.Core/Numpy/Slice.cs
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
-namespace Tensorflow.Numpy
+namespace Tensorflow.NumPy
{
///
/// NDArray can be indexed using slicing
diff --git a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
index 7fa1bf54..5130e763 100644
--- a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
+++ b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Core/Operations/Operation.cs b/src/TensorFlowNET.Core/Operations/Operation.cs
index 8ada07dd..a3bfcdf0 100644
--- a/src/TensorFlowNET.Core/Operations/Operation.cs
+++ b/src/TensorFlowNET.Core/Operations/Operation.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Core/Operations/array_ops.cs b/src/TensorFlowNET.Core/Operations/array_ops.cs
index e7c34be6..df229252 100644
--- a/src/TensorFlowNET.Core/Operations/array_ops.cs
+++ b/src/TensorFlowNET.Core/Operations/array_ops.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -186,7 +186,7 @@ namespace Tensorflow
private static Tensor _constant_if_small(int value, Tensor shape)
{
- return shape < 1000;
+ return shape < 1000L;
}
private static Tensor _constant_if_small(T value, TensorShape shape, TF_DataType dtype, string name)
@@ -212,7 +212,7 @@ namespace Tensorflow
return _autopacking_helper(v, dtype, name == null ? "packed" : name);
}
- private static TF_DataType _get_dtype_from_nested_lists(IEnumerable
public Tensor(bool[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(bool)), new long[] { data.Length }, data, sizeof(bool));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(bool)), new long[] { data.Length }, data, sizeof(bool));
}
///
@@ -184,12 +188,12 @@ namespace Tensorflow
///
public Tensor(bool[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(bool)), shape, data, sizeof(bool));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(bool)), shape, data, sizeof(bool));
}
internal Tensor(float[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(bool)), shape, data, sizeof(bool));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(bool)), shape, data, sizeof(bool));
}
///
@@ -197,7 +201,7 @@ namespace Tensorflow
///
public unsafe Tensor(bool value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(bool)), dims: new long[0], num_dims: 0, len: sizeof(bool));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(bool)), dims: new long[0], num_dims: 0, len: sizeof(bool));
*(bool*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -207,7 +211,7 @@ namespace Tensorflow
///
public Tensor(byte[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(byte)), new long[] { data.Length }, data, sizeof(byte));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(byte)), new long[] { data.Length }, data, sizeof(byte));
}
///
@@ -215,7 +219,7 @@ namespace Tensorflow
///
public Tensor(byte[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(byte)), shape, data, sizeof(byte));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(byte)), shape, data, sizeof(byte));
}
///
@@ -223,7 +227,7 @@ namespace Tensorflow
///
public unsafe Tensor(byte value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(byte)), dims: new long[0], num_dims: 0, len: sizeof(byte));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(byte)), dims: new long[0], num_dims: 0, len: sizeof(byte));
*(byte*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -233,7 +237,7 @@ namespace Tensorflow
///
public Tensor(short[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(short)), new long[] { data.Length }, data, sizeof(short));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(short)), new long[] { data.Length }, data, sizeof(short));
}
///
@@ -241,7 +245,7 @@ namespace Tensorflow
///
public Tensor(short[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(short)), shape, data, sizeof(short));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(short)), shape, data, sizeof(short));
}
///
@@ -249,7 +253,7 @@ namespace Tensorflow
///
public unsafe Tensor(short value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(short)), dims: new long[0], num_dims: 0, len: sizeof(short));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(short)), dims: new long[0], num_dims: 0, len: sizeof(short));
*(short*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -259,7 +263,7 @@ namespace Tensorflow
///
public Tensor(ushort[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ushort)), new long[] { data.Length }, data, sizeof(ushort));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(ushort)), new long[] { data.Length }, data, sizeof(ushort));
}
///
@@ -267,7 +271,7 @@ namespace Tensorflow
///
public Tensor(ushort[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ushort)), shape, data, sizeof(ushort));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(ushort)), shape, data, sizeof(ushort));
}
///
@@ -275,7 +279,7 @@ namespace Tensorflow
///
public unsafe Tensor(ushort value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(ushort)), dims: new long[0], num_dims: 0, len: sizeof(ushort));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(ushort)), dims: new long[0], num_dims: 0, len: sizeof(ushort));
*(ushort*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -285,7 +289,7 @@ namespace Tensorflow
///
public Tensor(int[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(int)), new long[] { data.Length }, data, sizeof(int));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(int)), new long[] { data.Length }, data, sizeof(int));
}
///
@@ -293,7 +297,7 @@ namespace Tensorflow
///
public Tensor(int[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(int)), shape, data, sizeof(int));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(int)), shape, data, sizeof(int));
}
///
@@ -301,7 +305,7 @@ namespace Tensorflow
///
public unsafe Tensor(int value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(int)), dims: new long[0], num_dims: 0, len: sizeof(int));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(int)), dims: new long[0], num_dims: 0, len: sizeof(int));
*(int*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -311,7 +315,7 @@ namespace Tensorflow
///
public Tensor(uint[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(uint)), new long[] { data.Length }, data, sizeof(uint));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(uint)), new long[] { data.Length }, data, sizeof(uint));
}
///
@@ -319,7 +323,7 @@ namespace Tensorflow
///
public Tensor(uint[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(uint)), shape, data, sizeof(uint));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(uint)), shape, data, sizeof(uint));
}
///
@@ -327,7 +331,7 @@ namespace Tensorflow
///
public unsafe Tensor(uint value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(uint)), dims: new long[0], num_dims: 0, len: sizeof(uint));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(uint)), dims: new long[0], num_dims: 0, len: sizeof(uint));
*(uint*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -337,7 +341,7 @@ namespace Tensorflow
///
public Tensor(long[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(long)), new long[] { data.Length }, data, sizeof(long));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(long)), new long[] { data.Length }, data, sizeof(long));
}
///
@@ -345,7 +349,7 @@ namespace Tensorflow
///
public Tensor(long[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(long)), shape, data, sizeof(long));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(long)), shape, data, sizeof(long));
}
///
@@ -353,7 +357,7 @@ namespace Tensorflow
///
public unsafe Tensor(long value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(long)), dims: new long[0], num_dims: 0, len: sizeof(long));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(long)), dims: new long[0], num_dims: 0, len: sizeof(long));
*(long*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -363,7 +367,7 @@ namespace Tensorflow
///
public Tensor(ulong[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ulong)), new long[] { data.Length }, data, sizeof(ulong));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(ulong)), new long[] { data.Length }, data, sizeof(ulong));
}
///
@@ -371,7 +375,7 @@ namespace Tensorflow
///
public Tensor(ulong[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ulong)), shape, data, sizeof(ulong));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(ulong)), shape, data, sizeof(ulong));
}
///
@@ -379,7 +383,7 @@ namespace Tensorflow
///
public unsafe Tensor(ulong value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(ulong)), dims: new long[0], num_dims: 0, len: sizeof(ulong));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(ulong)), dims: new long[0], num_dims: 0, len: sizeof(ulong));
*(ulong*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -397,7 +401,7 @@ namespace Tensorflow
///
public unsafe Tensor(float value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(float)), dims: new long[0], num_dims: 0, len: sizeof(float));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(float)), dims: new long[0], num_dims: 0, len: sizeof(float));
*(float*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -407,7 +411,7 @@ namespace Tensorflow
///
public Tensor(double[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(double)), new long[] { data.Length }, data, sizeof(double));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(double)), new long[] { data.Length }, data, sizeof(double));
}
///
@@ -415,7 +419,7 @@ namespace Tensorflow
///
public Tensor(double[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(double)), shape, data, sizeof(double));
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(double)), shape, data, sizeof(double));
}
///
@@ -423,7 +427,7 @@ namespace Tensorflow
///
public unsafe Tensor(double value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(double)), dims: new long[0], num_dims: 0, len: sizeof(double));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(double)), dims: new long[0], num_dims: 0, len: sizeof(double));
*(double*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -433,7 +437,7 @@ namespace Tensorflow
///
public Tensor(Complex[] data, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(Complex)), new long[] { data.Length }, data, Marshal.SizeOf());
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(Complex)), new long[] { data.Length }, data, Marshal.SizeOf());
}
///
@@ -441,7 +445,7 @@ namespace Tensorflow
///
public Tensor(Complex[] data, long[] shape, TF_DataType? dType = null)
{
- _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(Complex)), shape, data, Marshal.SizeOf());
+ _handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(Complex)), shape, data, Marshal.SizeOf());
}
///
@@ -449,7 +453,7 @@ namespace Tensorflow
///
public unsafe Tensor(Complex value, TF_DataType? dType = null)
{
- _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(Complex)), dims: new long[0], num_dims: 0, len: (ulong)sizeof(Complex));
+ _handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(Complex)), dims: new long[0], num_dims: 0, len: (ulong)sizeof(Complex));
*(Complex*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs
index a96f3a14..d4a5f11e 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using static Tensorflow.Binding;
@@ -19,8 +19,5 @@ namespace Tensorflow
public static implicit operator Tensor(IntPtr handle)
=> new Tensor(handle);
-
- public static implicit operator Tensor(NDArray nd)
- => tf.convert_to_tensor(nd);
}
}
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs
index 1f55abc4..c8f47825 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs
index 4ea94585..7ed1e423 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Numerics;
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs
index e3f285f4..053f83fa 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Text;
using static Tensorflow.Binding;
@@ -21,7 +21,7 @@ namespace Tensorflow
public T[] ToArray() where T : unmanaged
{
//Are the types matching?
- if (typeof(T).as_dtype() == dtype)
+ if (typeof(T).as_tf_dtype() == dtype)
{
if (NDims == 0 && size == 1) //is it a scalar?
{
diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.cs b/src/TensorFlowNET.Core/Tensors/Tensor.cs
index 8d108ea5..d1a133df 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensor.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensor.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
diff --git a/src/TensorFlowNET.Core/Tensors/TensorConverter.cs b/src/TensorFlowNET.Core/Tensors/TensorConverter.cs
index 27aa9d8e..43ba4eb4 100644
--- a/src/TensorFlowNET.Core/Tensors/TensorConverter.cs
+++ b/src/TensorFlowNET.Core/Tensors/TensorConverter.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Threading.Tasks;
using Tensorflow.Util;
@@ -122,7 +122,7 @@ namespace Tensorflow
if (astype == null)
{
//No conversion required
- var constantType = typeof(T).as_dtype();
+ var constantType = typeof(T).as_tf_dtype();
if (constantType == TF_DataType.TF_INT8)
return new Tensor((sbyte)(object)constant);
diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs
index b984f772..45627b0e 100644
--- a/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs
+++ b/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.cs
index 847e42a6..2d3f9b67 100644
--- a/src/TensorFlowNET.Core/Tensors/TensorShape.cs
+++ b/src/TensorFlowNET.Core/Tensors/TensorShape.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/TensorFlowNET.Core/Tensors/Tensors.cs b/src/TensorFlowNET.Core/Tensors/Tensors.cs
index 467657f4..4b191aa0 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensors.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensors.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/TensorFlowNET.Core/Tensors/c_api.tensor.cs b/src/TensorFlowNET.Core/Tensors/c_api.tensor.cs
index e4150a11..fbf966e6 100644
--- a/src/TensorFlowNET.Core/Tensors/c_api.tensor.cs
+++ b/src/TensorFlowNET.Core/Tensors/c_api.tensor.cs
@@ -17,7 +17,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Tensors/constant_op.cs b/src/TensorFlowNET.Core/Tensors/constant_op.cs
index 7d731a9f..9a6e4837 100644
--- a/src/TensorFlowNET.Core/Tensors/constant_op.cs
+++ b/src/TensorFlowNET.Core/Tensors/constant_op.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -127,7 +127,7 @@ namespace Tensorflow
if (dtype != TF_DataType.DtInvalid &&
value.GetType().Name != "NDArray" &&
value.GetType().BaseType.Name != "Array" &&
- dtypes.as_base_dtype(dtype) != dtypes.as_dtype(value.GetType()))
+ dtypes.as_base_dtype(dtype) != dtypes.as_tf_dtype(value.GetType()))
{
switch (dtype)
{
@@ -169,9 +169,9 @@ namespace Tensorflow
case string[] val:
return new EagerTensor(val, ctx.DeviceName);
case bool val:
- return new EagerTensor(val, ctx.DeviceName);
+ return new EagerTensor(new[] { val }, Shape.Scalar);
case byte val:
- return new EagerTensor(val, ctx.DeviceName);
+ return new EagerTensor(new[] { val }, Shape.Scalar);
case byte[] val:
return new EagerTensor(val, ctx.DeviceName);
case byte[,] val:
@@ -187,7 +187,7 @@ namespace Tensorflow
case int[,,] val:
return new EagerTensor(val, ctx.DeviceName);
case long val:
- return new EagerTensor(val, ctx.DeviceName);
+ return new EagerTensor(new[] { val }, Shape.Scalar);
case long[] val:
return new EagerTensor(val, new Shape(val.Length));
case long[,] val:
diff --git a/src/TensorFlowNET.Core/Tensors/dtypes.cs b/src/TensorFlowNET.Core/Tensors/dtypes.cs
index c38149de..5d9c026e 100644
--- a/src/TensorFlowNET.Core/Tensors/dtypes.cs
+++ b/src/TensorFlowNET.Core/Tensors/dtypes.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Numerics;
@@ -126,7 +126,7 @@ namespace Tensorflow
///
///
/// When has no equivalent
- public static TF_DataType as_dtype(this Type type, TF_DataType? dtype = null)
+ public static TF_DataType as_tf_dtype(this Type type, TF_DataType? dtype = null)
{
switch (type.Name)
{
diff --git a/src/TensorFlowNET.Core/Tensors/tensor_util.cs b/src/TensorFlowNET.Core/Tensors/tensor_util.cs
index 3393ca8d..367b02ca 100644
--- a/src/TensorFlowNET.Core/Tensors/tensor_util.cs
+++ b/src/TensorFlowNET.Core/Tensors/tensor_util.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -75,19 +75,19 @@ namespace Tensorflow
}
else if (tensor.Dtype == DataType.DtHalf || tensor.Dtype == DataType.DtBfloat16)
{
- return np.array(tensor.HalfVal).reshape(shape);
+ return np.array(tensor.HalfVal.ToArray()).reshape(shape);
}
else if (tensor.Dtype == DataType.DtFloat)
{
- return np.array(tensor.FloatVal).reshape(shape);
+ return np.array(tensor.FloatVal.ToArray()).reshape(shape);
}
else if (new DataType[] { DataType.DtInt32, DataType.DtUint8 }.Contains(tensor.Dtype))
{
- return np.array(tensor.IntVal).reshape(shape);
+ return np.array(tensor.IntVal.ToArray()).reshape(shape);
}
else if (tensor.Dtype == DataType.DtBool)
{
- return np.array(tensor.BoolVal).reshape(shape);
+ return np.array(tensor.BoolVal.ToArray()).reshape(shape);
}
throw new NotImplementedException("MakeNdarray");
@@ -284,7 +284,7 @@ scalar with value '-1' to describe an unknown shape.", value_));
var pre_cast = constant_value_as_shape(tensor.op.inputs[0]);
if (pre_cast.dims == null)
return pre_cast;
- var cast_dtype = dtypes.as_dtype((Type)tensor.op.get_attr("DstT"));
+ var cast_dtype = dtypes.as_tf_dtype((Type)tensor.op.get_attr("DstT"));
if (!Array.Exists(new[] { dtypes.int32, dtypes.int64 }, cast_dtype_ => cast_dtype_ == cast_dtype))
return tensor.TensorShape.unknown_shape((int)shape.dims[0]);
@@ -594,35 +594,43 @@ would not be rank 1.", tensor.op.get_attr("axis")));
{
return "";
}
+ else if (dtype == TF_DataType.TF_BOOL)
+ {
+ var array = tensor.ToArray();
+ return DisplayArrayAsString(array, tensor.shape);
+ }
else if (dtype == TF_DataType.TF_INT32)
{
var array = tensor.ToArray();
- return DisplayArrayAsString(array);
+ return DisplayArrayAsString(array, tensor.shape);
}
else if (dtype == TF_DataType.TF_INT64)
{
var array = tensor.ToArray();
- return DisplayArrayAsString(array);
+ return DisplayArrayAsString(array, tensor.shape);
}
else if (dtype == TF_DataType.TF_FLOAT)
{
var array = tensor.ToArray();
- return DisplayArrayAsString(array);
+ return DisplayArrayAsString(array, tensor.shape);
}
else if(dtype == TF_DataType.TF_DOUBLE)
{
var array = tensor.ToArray();
- return DisplayArrayAsString(array);
+ return DisplayArrayAsString(array, tensor.shape);
}
else
{
var array = tensor.ToArray();
- return DisplayArrayAsString(array);
+ return DisplayArrayAsString(array, tensor.shape);
}
}
- static string DisplayArrayAsString(T[] array)
+ static string DisplayArrayAsString(T[] array, Shape shape)
{
+ if (shape.ndim == 0)
+ return array[0].ToString();
+
var display = "[";
if (array.Length < 10)
display += string.Join(", ", array);
diff --git a/src/TensorFlowNET.Core/Training/Saving/Saver.cs b/src/TensorFlowNET.Core/Training/Saving/Saver.cs
index ec15564c..c326267f 100644
--- a/src/TensorFlowNET.Core/Training/Saving/Saver.cs
+++ b/src/TensorFlowNET.Core/Training/Saving/Saver.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/src/TensorFlowNET.Core/Util/nest.py.cs b/src/TensorFlowNET.Core/Util/nest.py.cs
index a5548dcb..d04e6bff 100644
--- a/src/TensorFlowNET.Core/Util/nest.py.cs
+++ b/src/TensorFlowNET.Core/Util/nest.py.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Collections.Generic;
diff --git a/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs b/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs
index 969d2deb..accea30f 100644
--- a/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs
+++ b/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using Tensorflow.Eager;
using Tensorflow.Variables;
diff --git a/src/TensorFlowNET.Core/Variables/IVariableV1.cs b/src/TensorFlowNET.Core/Variables/IVariableV1.cs
index 183ce6f6..01c5d2ec 100644
--- a/src/TensorFlowNET.Core/Variables/IVariableV1.cs
+++ b/src/TensorFlowNET.Core/Variables/IVariableV1.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/Variables/RefVariable.cs b/src/TensorFlowNET.Core/Variables/RefVariable.cs
index 7dcd0f8b..3bf4f784 100644
--- a/src/TensorFlowNET.Core/Variables/RefVariable.cs
+++ b/src/TensorFlowNET.Core/Variables/RefVariable.cs
@@ -15,7 +15,7 @@
******************************************************************************/
using Google.Protobuf;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.Index.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.Index.cs
index 0b3c7a3e..879a38e4 100644
--- a/src/TensorFlowNET.Core/Variables/ResourceVariable.Index.cs
+++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.Index.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs
index efbd5b11..0b0a49cd 100644
--- a/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs
+++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow
{
diff --git a/src/TensorFlowNET.Core/ops.cs b/src/TensorFlowNET.Core/ops.cs
index e5b944e2..c0b81740 100644
--- a/src/TensorFlowNET.Core/ops.cs
+++ b/src/TensorFlowNET.Core/ops.cs
@@ -16,7 +16,7 @@
using Google.Protobuf;
using Google.Protobuf.Collections;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -126,8 +126,15 @@ namespace Tensorflow
if (value is EagerTensor eager_tensor)
{
+ if (dtype == TF_DataType.DtInvalid)
+ dtype = eager_tensor.dtype;
+
if (tf.executing_eagerly())
+ {
+ if (dtype != eager_tensor.dtype)
+ return gen_math_ops.cast(eager_tensor, dtype.as_base_dtype(), name: name);
return eager_tensor;
+ }
else
{
var graph = get_default_graph();
@@ -136,6 +143,8 @@ namespace Tensorflow
return (graph as FuncGraph).capture(eager_tensor, name: name);
}
}
+ else if (value is NDArray nd)
+ return nd;
Tensor ret = value switch
{
diff --git a/src/TensorFlowNET.Keras/BackendImpl.cs b/src/TensorFlowNET.Keras/BackendImpl.cs
index 2a6f96f1..7ce07809 100644
--- a/src/TensorFlowNET.Keras/BackendImpl.cs
+++ b/src/TensorFlowNET.Keras/BackendImpl.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using System.Collections.Generic;
diff --git a/src/TensorFlowNET.Keras/Datasets/Cifar10.cs b/src/TensorFlowNET.Keras/Datasets/Cifar10.cs
index 1c4ee473..a0ccfdef 100644
--- a/src/TensorFlowNET.Keras/Datasets/Cifar10.cs
+++ b/src/TensorFlowNET.Keras/Datasets/Cifar10.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/src/TensorFlowNET.Keras/Datasets/DatasetPass.cs b/src/TensorFlowNET.Keras/Datasets/DatasetPass.cs
index 9f6242f3..80bafaa3 100644
--- a/src/TensorFlowNET.Keras/Datasets/DatasetPass.cs
+++ b/src/TensorFlowNET.Keras/Datasets/DatasetPass.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow.Keras.Datasets
{
diff --git a/src/TensorFlowNET.Keras/Datasets/Imdb.cs b/src/TensorFlowNET.Keras/Datasets/Imdb.cs
index 16c3562a..b809b1c4 100644
--- a/src/TensorFlowNET.Keras/Datasets/Imdb.cs
+++ b/src/TensorFlowNET.Keras/Datasets/Imdb.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Tensorflow.Keras.Utils;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
namespace Tensorflow.Keras.Datasets
diff --git a/src/TensorFlowNET.Keras/Datasets/MNIST.cs b/src/TensorFlowNET.Keras/Datasets/MNIST.cs
index 33974c9b..0e2dd218 100644
--- a/src/TensorFlowNET.Keras/Datasets/MNIST.cs
+++ b/src/TensorFlowNET.Keras/Datasets/MNIST.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.IO;
using Tensorflow.Keras.Utils;
diff --git a/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs b/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs
index 7c5c93c2..d0d4f5ea 100644
--- a/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs
+++ b/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Engine/Model.Fit.cs b/src/TensorFlowNET.Keras/Engine/Model.Fit.cs
index f711b7fe..41eaecd0 100644
--- a/src/TensorFlowNET.Keras/Engine/Model.Fit.cs
+++ b/src/TensorFlowNET.Keras/Engine/Model.Fit.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Engine/Model.Predict.cs b/src/TensorFlowNET.Keras/Engine/Model.Predict.cs
index d722cd53..109ab4b9 100644
--- a/src/TensorFlowNET.Keras/Engine/Model.Predict.cs
+++ b/src/TensorFlowNET.Keras/Engine/Model.Predict.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Engine/Model.Training.cs b/src/TensorFlowNET.Keras/Engine/Model.Training.cs
index d494f226..02dccc92 100644
--- a/src/TensorFlowNET.Keras/Engine/Model.Training.cs
+++ b/src/TensorFlowNET.Keras/Engine/Model.Training.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using HDF.PInvoke;
using HDF5CSharp;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow.Keras.Saving;
namespace Tensorflow.Keras.Engine
diff --git a/src/TensorFlowNET.Keras/Layers/LayersApi.Merging.cs b/src/TensorFlowNET.Keras/Layers/LayersApi.Merging.cs
index f5301eff..ecf8c0a6 100644
--- a/src/TensorFlowNET.Keras/Layers/LayersApi.Merging.cs
+++ b/src/TensorFlowNET.Keras/Layers/LayersApi.Merging.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/TensorFlowNET.Keras/Layers/LayersApi.Reshaping.cs b/src/TensorFlowNET.Keras/Layers/LayersApi.Reshaping.cs
index b3249459..81494408 100644
--- a/src/TensorFlowNET.Keras/Layers/LayersApi.Reshaping.cs
+++ b/src/TensorFlowNET.Keras/Layers/LayersApi.Reshaping.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/TensorFlowNET.Keras/Layers/LayersApi.cs b/src/TensorFlowNET.Keras/Layers/LayersApi.cs
index c7bc3cc1..1b5e9c24 100644
--- a/src/TensorFlowNET.Keras/Layers/LayersApi.cs
+++ b/src/TensorFlowNET.Keras/Layers/LayersApi.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Collections.Generic;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
diff --git a/src/TensorFlowNET.Keras/Layers/Reshaping/ZeroPadding2D.cs b/src/TensorFlowNET.Keras/Layers/Reshaping/ZeroPadding2D.cs
index 922bd719..7c87100a 100644
--- a/src/TensorFlowNET.Keras/Layers/Reshaping/ZeroPadding2D.cs
+++ b/src/TensorFlowNET.Keras/Layers/Reshaping/ZeroPadding2D.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
using Tensorflow.Keras.Utils;
diff --git a/src/TensorFlowNET.Keras/Layers/TensorFlowOpLayer.cs b/src/TensorFlowNET.Keras/Layers/TensorFlowOpLayer.cs
index a8075e84..288911c7 100644
--- a/src/TensorFlowNET.Keras/Layers/TensorFlowOpLayer.cs
+++ b/src/TensorFlowNET.Keras/Layers/TensorFlowOpLayer.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs b/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs
index cd2f6e90..e406176d 100644
--- a/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs
+++ b/src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
index 96399b5a..ca69924e 100644
--- a/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
+++ b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
@@ -1,6 +1,6 @@
using static Tensorflow.KerasApi;
using static Tensorflow.Binding;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace Tensorflow.Keras
{
diff --git a/src/TensorFlowNET.Keras/Preprocessings/Tokenizer.cs b/src/TensorFlowNET.Keras/Preprocessings/Tokenizer.cs
index 1bf4dd02..e5a295a7 100644
--- a/src/TensorFlowNET.Keras/Preprocessings/Tokenizer.cs
+++ b/src/TensorFlowNET.Keras/Preprocessings/Tokenizer.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Serilog.Debugging;
using System;
using System.Collections.Generic;
diff --git a/src/TensorFlowNET.Keras/Saving/hdf5_format.cs b/src/TensorFlowNET.Keras/Saving/hdf5_format.cs
index a6e5f2db..9f4ff149 100644
--- a/src/TensorFlowNET.Keras/Saving/hdf5_format.cs
+++ b/src/TensorFlowNET.Keras/Saving/hdf5_format.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text;
using HDF.PInvoke;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow.Keras.Engine;
using HDF5CSharp;
using static Tensorflow.Binding;
diff --git a/src/TensorFlowNET.Keras/Sequence.cs b/src/TensorFlowNET.Keras/Sequence.cs
index 44c3c4a6..4f10abfa 100644
--- a/src/TensorFlowNET.Keras/Sequence.cs
+++ b/src/TensorFlowNET.Keras/Sequence.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Utils/base_layer_utils.cs b/src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
index 7ae194bc..1e6ce409 100644
--- a/src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
+++ b/src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Utils/layer_utils.cs b/src/TensorFlowNET.Keras/Utils/layer_utils.cs
index e9c2eb30..be98b645 100644
--- a/src/TensorFlowNET.Keras/Utils/layer_utils.cs
+++ b/src/TensorFlowNET.Keras/Utils/layer_utils.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/TensorFlowNET.Keras/Utils/np_utils.cs b/src/TensorFlowNET.Keras/Utils/np_utils.cs
index c079ff15..1ae0c9c4 100644
--- a/src/TensorFlowNET.Keras/Utils/np_utils.cs
+++ b/src/TensorFlowNET.Keras/Utils/np_utils.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/TensorFlowNET.Text/Tokenizers/WhitespaceTokenizer.cs b/src/TensorFlowNET.Text/Tokenizers/WhitespaceTokenizer.cs
index 6be32274..46231546 100644
--- a/src/TensorFlowNET.Text/Tokenizers/WhitespaceTokenizer.cs
+++ b/src/TensorFlowNET.Text/Tokenizers/WhitespaceTokenizer.cs
@@ -1,4 +1,4 @@
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/TensorFlowNet.Benchmarks/Crash/RepeatDataSetCrash.cs b/src/TensorFlowNet.Benchmarks/Crash/RepeatDataSetCrash.cs
index 03f3d93c..16ee55fc 100644
--- a/src/TensorFlowNet.Benchmarks/Crash/RepeatDataSetCrash.cs
+++ b/src/TensorFlowNet.Benchmarks/Crash/RepeatDataSetCrash.cs
@@ -1,7 +1,7 @@
using BenchmarkDotNet.Attributes;
using System;
using System.Collections.Generic;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using static Tensorflow.Binding;
using static Tensorflow.KerasApi;
diff --git a/src/TensorFlowNet.Benchmarks/Leak/GpuLeakByCNN.cs b/src/TensorFlowNet.Benchmarks/Leak/GpuLeakByCNN.cs
index cef3bb05..8ea6cde5 100644
--- a/src/TensorFlowNet.Benchmarks/Leak/GpuLeakByCNN.cs
+++ b/src/TensorFlowNet.Benchmarks/Leak/GpuLeakByCNN.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
using Tensorflow.Keras.Layers;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow.Keras;
using static Tensorflow.Binding;
using static Tensorflow.KerasApi;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/ActivationTest.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/ActivationTest.cs
index c97cc317..3bd6a3a5 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/ActivationTest.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/ActivationTest.cs
@@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using static Tensorflow.KerasApi;
using Tensorflow;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/CosineSimilarity.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/CosineSimilarity.Test.cs
index 14f9d336..71a43627 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/CosineSimilarity.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/CosineSimilarity.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/Huber.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/Huber.Test.cs
index 28bee414..ca18b743 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/Huber.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/Huber.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Convolution.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Convolution.Test.cs
index de10f3cc..6fc58d9f 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Convolution.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Convolution.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Operations;
using static Tensorflow.KerasApi;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Merging.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Merging.Test.cs
index 604c4d0f..b8532088 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Merging.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Merging.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using static Tensorflow.KerasApi;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Reshaping.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Reshaping.Test.cs
index 6c897224..b09654bb 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Reshaping.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/Layers.Reshaping.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using static Tensorflow.Binding;
using static Tensorflow.KerasApi;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/LayersTest.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/LayersTest.cs
index 5efeaabf..abceb499 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/LayersTest.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/LayersTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Collections.Generic;
using Tensorflow;
using Tensorflow.Keras;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/LogCosh.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/LogCosh.Test.cs
index ae81c2f1..7c521a50 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/LogCosh.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/LogCosh.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsoluteError.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsoluteError.Test.cs
index fd70dd5f..c303fd74 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsoluteError.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsoluteError.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsolutePercentageError.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsolutePercentageError.Test.cs
index 12bb247a..4adda82a 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsolutePercentageError.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanAbsolutePercentageError.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredError.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredError.Test.cs
index 9ad4a990..62eccec2 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredError.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredError.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredLogarithmicError.Test.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredLogarithmicError.Test.cs
index d55fe828..e6b22277 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredLogarithmicError.Test.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/MeanSquaredLogarithmicError.Test.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using Tensorflow.Keras.Losses;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/Layers/PoolingTest.cs b/test/TensorFlowNET.Keras.UnitTest/Layers/PoolingTest.cs
index 8c9c1c3a..8af40855 100644
--- a/test/TensorFlowNET.Keras.UnitTest/Layers/PoolingTest.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/Layers/PoolingTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
using Tensorflow;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.Keras.UnitTest/PreprocessingTests.cs b/test/TensorFlowNET.Keras.UnitTest/PreprocessingTests.cs
index 465f8007..67494a0e 100644
--- a/test/TensorFlowNET.Keras.UnitTest/PreprocessingTests.cs
+++ b/test/TensorFlowNET.Keras.UnitTest/PreprocessingTests.cs
@@ -3,7 +3,7 @@ using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using static Tensorflow.KerasApi;
using Tensorflow;
using Tensorflow.Keras.Datasets;
diff --git a/test/TensorFlowNET.Native.UnitTest/Gradients/GradientsTest.cs b/test/TensorFlowNET.Native.UnitTest/Gradients/GradientsTest.cs
index 1bdecb9c..b85d3d83 100644
--- a/test/TensorFlowNET.Native.UnitTest/Gradients/GradientsTest.cs
+++ b/test/TensorFlowNET.Native.UnitTest/Gradients/GradientsTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using Tensorflow.Util;
diff --git a/test/TensorFlowNET.Native.UnitTest/Tensors/TensorTest.cs b/test/TensorFlowNET.Native.UnitTest/Tensors/TensorTest.cs
index 48e872db..c8e3093e 100644
--- a/test/TensorFlowNET.Native.UnitTest/Tensors/TensorTest.cs
+++ b/test/TensorFlowNET.Native.UnitTest/Tensors/TensorTest.cs
@@ -1,6 +1,6 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using System.Runtime.InteropServices;
diff --git a/test/TensorFlowNET.UnitTest/Basics/RandomTest.cs b/test/TensorFlowNET.UnitTest/Basics/RandomTest.cs
index c02222ab..d5c134c8 100644
--- a/test/TensorFlowNET.UnitTest/Basics/RandomTest.cs
+++ b/test/TensorFlowNET.UnitTest/Basics/RandomTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using Tensorflow;
diff --git a/test/TensorFlowNET.UnitTest/Basics/SessionTest.cs b/test/TensorFlowNET.UnitTest/Basics/SessionTest.cs
index 721fd4e0..4caa6395 100644
--- a/test/TensorFlowNET.UnitTest/Basics/SessionTest.cs
+++ b/test/TensorFlowNET.UnitTest/Basics/SessionTest.cs
@@ -1,6 +1,6 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/test/TensorFlowNET.UnitTest/Basics/TensorShapeTest.cs b/test/TensorFlowNET.UnitTest/Basics/TensorShapeTest.cs
index 79d88b1a..087f2413 100644
--- a/test/TensorFlowNET.UnitTest/Basics/TensorShapeTest.cs
+++ b/test/TensorFlowNET.UnitTest/Basics/TensorShapeTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using Tensorflow;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/Basics/TensorTest.cs b/test/TensorFlowNET.UnitTest/Basics/TensorTest.cs
index 712428d9..5c8cf52a 100644
--- a/test/TensorFlowNET.UnitTest/Basics/TensorTest.cs
+++ b/test/TensorFlowNET.UnitTest/Basics/TensorTest.cs
@@ -1,6 +1,6 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using System.Runtime.InteropServices;
diff --git a/test/TensorFlowNET.UnitTest/Basics/VariableTest.cs b/test/TensorFlowNET.UnitTest/Basics/VariableTest.cs
index 70b03d70..40b36583 100644
--- a/test/TensorFlowNET.UnitTest/Basics/VariableTest.cs
+++ b/test/TensorFlowNET.UnitTest/Basics/VariableTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/GradientTest/GradientEagerTest.cs b/test/TensorFlowNET.UnitTest/GradientTest/GradientEagerTest.cs
index eb772d1d..4e82e788 100644
--- a/test/TensorFlowNET.UnitTest/GradientTest/GradientEagerTest.cs
+++ b/test/TensorFlowNET.UnitTest/GradientTest/GradientEagerTest.cs
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Tensorflow;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow.UnitTest;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/GradientTest/GradientTest.cs b/test/TensorFlowNET.UnitTest/GradientTest/GradientTest.cs
index c9f304c9..143b40e3 100644
--- a/test/TensorFlowNET.UnitTest/GradientTest/GradientTest.cs
+++ b/test/TensorFlowNET.UnitTest/GradientTest/GradientTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/test/TensorFlowNET.UnitTest/ImageTest.cs b/test/TensorFlowNET.UnitTest/ImageTest.cs
index b75f1475..02f88fe6 100644
--- a/test/TensorFlowNET.UnitTest/ImageTest.cs
+++ b/test/TensorFlowNET.UnitTest/ImageTest.cs
@@ -1,6 +1,6 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
using Tensorflow;
using Tensorflow.UnitTest;
diff --git a/test/TensorFlowNET.UnitTest/ManagedAPI/ArrayOpsTest.cs b/test/TensorFlowNET.UnitTest/ManagedAPI/ArrayOpsTest.cs
index 3a38dff0..1d8ac0e0 100644
--- a/test/TensorFlowNET.UnitTest/ManagedAPI/ArrayOpsTest.cs
+++ b/test/TensorFlowNET.UnitTest/ManagedAPI/ArrayOpsTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/ManagedAPI/ConstantTest.cs b/test/TensorFlowNET.UnitTest/ManagedAPI/ConstantTest.cs
index f364750d..ebba95f0 100644
--- a/test/TensorFlowNET.UnitTest/ManagedAPI/ConstantTest.cs
+++ b/test/TensorFlowNET.UnitTest/ManagedAPI/ConstantTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Linq;
using Tensorflow;
diff --git a/test/TensorFlowNET.UnitTest/ManagedAPI/ControlFlowApiTest.cs b/test/TensorFlowNET.UnitTest/ManagedAPI/ControlFlowApiTest.cs
index d3752cb1..6e699bf4 100644
--- a/test/TensorFlowNET.UnitTest/ManagedAPI/ControlFlowApiTest.cs
+++ b/test/TensorFlowNET.UnitTest/ManagedAPI/ControlFlowApiTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using Tensorflow;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/ManagedAPI/GradientTest.cs b/test/TensorFlowNET.UnitTest/ManagedAPI/GradientTest.cs
index 639d5c8b..0bf506da 100644
--- a/test/TensorFlowNET.UnitTest/ManagedAPI/GradientTest.cs
+++ b/test/TensorFlowNET.UnitTest/ManagedAPI/GradientTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using Tensorflow;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/ManagedAPI/TensorOperate.cs b/test/TensorFlowNET.UnitTest/ManagedAPI/TensorOperate.cs
index 0595044f..cdc8b51c 100644
--- a/test/TensorFlowNET.UnitTest/ManagedAPI/TensorOperate.cs
+++ b/test/TensorFlowNET.UnitTest/ManagedAPI/TensorOperate.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;
diff --git a/test/TensorFlowNET.UnitTest/MultithreadingTests.cs b/test/TensorFlowNET.UnitTest/MultithreadingTests.cs
index a10b73a6..3e56ea66 100644
--- a/test/TensorFlowNET.UnitTest/MultithreadingTests.cs
+++ b/test/TensorFlowNET.UnitTest/MultithreadingTests.cs
@@ -1,6 +1,6 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.IO;
using System.Linq;
@@ -170,7 +170,7 @@ namespace TensorFlowNET.UnitTest
{
var v = (int*)Marshal.AllocHGlobal(sizeof(int));
c_api.DeallocatorArgs _deallocatorArgs = new c_api.DeallocatorArgs();
- var handle = c_api.TF_NewTensor(typeof(int).as_dtype(), dims: new long[0], num_dims: 0,
+ var handle = c_api.TF_NewTensor(typeof(int).as_tf_dtype(), dims: new long[0], num_dims: 0,
data: (IntPtr)v, len: (UIntPtr)sizeof(int),
deallocator: (IntPtr data, IntPtr size, ref c_api.DeallocatorArgs args) => Marshal.FreeHGlobal(data),
ref _deallocatorArgs);
diff --git a/test/TensorFlowNET.UnitTest/Numpy/Array.Creation.Test.cs b/test/TensorFlowNET.UnitTest/Numpy/Array.Creation.Test.cs
index 3ad3e528..ddaa7c1d 100644
--- a/test/TensorFlowNET.UnitTest/Numpy/Array.Creation.Test.cs
+++ b/test/TensorFlowNET.UnitTest/Numpy/Array.Creation.Test.cs
@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
namespace TensorFlowNET.UnitTest.Numpy
{
@@ -11,7 +11,7 @@ namespace TensorFlowNET.UnitTest.Numpy
/// https://numpy.org/doc/stable/reference/routines.array-creation.html
///
[TestClass]
- public class NumpyArrayCreationTest
+ public class NumpyArrayCreationTest : EagerModeTestBase
{
[TestMethod]
public void empty_zeros_ones_full()
@@ -26,25 +26,59 @@ namespace TensorFlowNET.UnitTest.Numpy
public void arange()
{
var x = np.arange(3);
- Assert.IsTrue(Enumerable.SequenceEqual(new[] { 0, 1, 2 }, x.Data()));
+ AssetSequenceEqual(new[] { 0, 1, 2 }, x.Data());
x = np.arange(3f);
- Assert.IsTrue(Enumerable.SequenceEqual(new float[] { 0, 1, 2 }, x.Data()));
+ Assert.IsTrue(Equal(new float[] { 0, 1, 2 }, x.Data()));
var y = np.arange(3, 7);
- Assert.IsTrue(Enumerable.SequenceEqual(new[] { 3, 4, 5, 6 }, y.Data()));
+ AssetSequenceEqual(new[] { 3, 4, 5, 6 }, y.Data());
+
y = np.arange(3, 7, 2);
- Assert.IsTrue(Enumerable.SequenceEqual(new[] { 3, 5 }, y.Data()));
+ AssetSequenceEqual(new[] { 3, 5 }, y.Data());
}
[TestMethod]
public void array()
{
var x = np.array(1, 2, 3);
- Assert.IsTrue(Enumerable.SequenceEqual(new[] { 1, 2, 3 }, x.Data()));
+ AssetSequenceEqual(new[] { 1, 2, 3 }, x.Data());
x = np.array(new[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } });
- Assert.IsTrue(Enumerable.SequenceEqual(new[] { 1, 2, 3, 4, 5, 6 }, x.Data()));
+ AssetSequenceEqual(new[] { 1, 2, 3, 4, 5, 6 }, x.Data());
+ }
+
+ [TestMethod]
+ public void eye()
+ {
+ var x = np.eye(3, k: 1);
+ Assert.IsTrue(Equal(new double[] { 0, 1, 0, 0, 0, 1, 0, 0, 0 }, x.Data()));
+ }
+
+ [TestMethod]
+ public void linspace()
+ {
+ var x = np.linspace(2.0, 3.0, num: 5);
+ Assert.IsTrue(Equal(new double[] { 2, 2.25, 2.5, 2.75, 3 }, x.Data()));
+
+ x = np.linspace(2.0, 3.0, num: 5, endpoint: false);
+ Assert.IsTrue(Equal(new double[] { 2, 2.2, 2.4, 2.6, 2.8 }, x.Data()));
+ }
+
+ [TestMethod]
+ public void meshgrid()
+ {
+ var x = np.linspace(0, 1, num: 3);
+ var y = np.linspace(0, 1, num: 2);
+ var (xv, yv) = np.meshgrid(x, y);
+ Assert.IsTrue(Equal(new double[] { 0, 0.5, 1, 0, 0.5, 1 }, xv.Data()));
+ Assert.IsTrue(Equal(new double[] { 0, 0, 0, 1, 1, 1 }, yv.Data()));
+
+ (xv, yv) = np.meshgrid(x, y, sparse: true);
+ Assert.IsTrue(Equal(new double[] { 0, 0.5, 1 }, xv.Data()));
+ AssetSequenceEqual(new long[] { 1, 3 }, xv.shape.dims);
+ Assert.IsTrue(Equal(new double[] { 0, 1 }, yv.Data()));
+ AssetSequenceEqual(new long[] { 2, 1 }, yv.shape.dims);
}
}
}
diff --git a/test/TensorFlowNET.UnitTest/OperationsTest.cs b/test/TensorFlowNET.UnitTest/OperationsTest.cs
index 449d41c4..f0101151 100644
--- a/test/TensorFlowNET.UnitTest/OperationsTest.cs
+++ b/test/TensorFlowNET.UnitTest/OperationsTest.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/test/TensorFlowNET.UnitTest/PythonTest.cs b/test/TensorFlowNET.UnitTest/PythonTest.cs
index 9fcf93be..8ab25ee6 100644
--- a/test/TensorFlowNET.UnitTest/PythonTest.cs
+++ b/test/TensorFlowNET.UnitTest/PythonTest.cs
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Linq;
@@ -327,6 +327,9 @@ namespace TensorFlowNET.UnitTest
#endregion
-
+ public void AssetSequenceEqual(T[] a, T[] b)
+ {
+ Assert.IsTrue(Enumerable.SequenceEqual(a, b));
+ }
}
}
diff --git a/test/TensorFlowNET.UnitTest/Utilities/FluentExtension.cs b/test/TensorFlowNET.UnitTest/Utilities/FluentExtension.cs
index 0f442f05..154ab714 100644
--- a/test/TensorFlowNET.UnitTest/Utilities/FluentExtension.cs
+++ b/test/TensorFlowNET.UnitTest/Utilities/FluentExtension.cs
@@ -1,7 +1,7 @@
using FluentAssertions;
using FluentAssertions.Execution;
using FluentAssertions.Primitives;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using System.Diagnostics;
using System.Linq;
diff --git a/test/TensorFlowNET.UnitTest/functional_ops_test/ScanTestCase.cs b/test/TensorFlowNET.UnitTest/functional_ops_test/ScanTestCase.cs
index 0e217e26..cf871cec 100644
--- a/test/TensorFlowNET.UnitTest/functional_ops_test/ScanTestCase.cs
+++ b/test/TensorFlowNET.UnitTest/functional_ops_test/ScanTestCase.cs
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using Tensorflow.Numpy;
+using Tensorflow.NumPy;
using System;
using Tensorflow;
using Tensorflow.UnitTest;