Browse Source

linspace and meshgrid.

tags/v0.60-tf.numpy
Oceania2018 4 years ago
parent
commit
3231500660
100 changed files with 393 additions and 174 deletions
  1. +1
    -1
      src/TensorFlowNET.Console/MemoryBasicTest.cs
  2. +1
    -1
      src/TensorFlowNET.Console/MemoryFuncGraphTest.cs
  3. +1
    -1
      src/TensorFlowNET.Console/MemoryKerasTest.cs
  4. +1
    -1
      src/TensorFlowNET.Console/MemoryMonitor.cs
  5. +1
    -1
      src/TensorFlowNET.Core/APIs/tf.array.cs
  6. +29
    -0
      src/TensorFlowNET.Core/APIs/tf.numpy.cs
  7. +4
    -1
      src/TensorFlowNET.Core/Binding.Util.cs
  8. +1
    -1
      src/TensorFlowNET.Core/Data/DataSetBase.cs
  9. +1
    -1
      src/TensorFlowNET.Core/Data/DatasetManager.cs
  10. +1
    -1
      src/TensorFlowNET.Core/Data/Datasets.cs
  11. +1
    -1
      src/TensorFlowNET.Core/Data/IDataSet.cs
  12. +1
    -1
      src/TensorFlowNET.Core/Data/MnistDataSet.cs
  13. +1
    -1
      src/TensorFlowNET.Core/Data/MnistModelLoader.cs
  14. +1
    -1
      src/TensorFlowNET.Core/Data/TensorDataset.cs
  15. +1
    -1
      src/TensorFlowNET.Core/Data/TensorSliceDataset.cs
  16. +1
    -1
      src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
  17. +1
    -1
      src/TensorFlowNET.Core/Framework/graph_util_impl.cs
  18. +1
    -1
      src/TensorFlowNET.Core/Framework/tensor_shape.cs
  19. +1
    -1
      src/TensorFlowNET.Core/Gradients/array_grad.cs
  20. +1
    -1
      src/TensorFlowNET.Core/Gradients/math_grad.cs
  21. +1
    -1
      src/TensorFlowNET.Core/Interfaces/ITensorOrOperation.cs
  22. +1
    -1
      src/TensorFlowNET.Core/Keras/ArgsDefinition/Reshaping/ZeroPadding2DArgs.cs
  23. +1
    -1
      src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs
  24. +71
    -0
      src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.Creation.cs
  25. +10
    -0
      src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.cs
  26. +1
    -1
      src/TensorFlowNET.Core/Numpy/IMemoryBlock.cs
  27. +1
    -1
      src/TensorFlowNET.Core/Numpy/InfoOf.cs
  28. +1
    -1
      src/TensorFlowNET.Core/Numpy/IteratorType.cs
  29. +1
    -1
      src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs
  30. +4
    -2
      src/TensorFlowNET.Core/Numpy/NDArray.cs
  31. +1
    -1
      src/TensorFlowNET.Core/Numpy/NDIterator.Generic.cs
  32. +1
    -1
      src/TensorFlowNET.Core/Numpy/NDIterator.cs
  33. +1
    -1
      src/TensorFlowNET.Core/Numpy/NpzDictionary.cs
  34. +14
    -10
      src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs
  35. +1
    -1
      src/TensorFlowNET.Core/Numpy/Numpy.cs
  36. +1
    -1
      src/TensorFlowNET.Core/Numpy/NumpyDType.cs
  37. +1
    -1
      src/TensorFlowNET.Core/Numpy/Shape.cs
  38. +1
    -1
      src/TensorFlowNET.Core/Numpy/Slice.cs
  39. +1
    -1
      src/TensorFlowNET.Core/Operations/NnOps/rnn.cs
  40. +1
    -1
      src/TensorFlowNET.Core/Operations/Operation.cs
  41. +44
    -7
      src/TensorFlowNET.Core/Operations/array_ops.cs
  42. +50
    -5
      src/TensorFlowNET.Core/Operations/math_ops.cs
  43. +1
    -1
      src/TensorFlowNET.Core/Operations/nn_impl.py.cs
  44. +1
    -1
      src/TensorFlowNET.Core/Operations/string_ops.cs
  45. +1
    -1
      src/TensorFlowNET.Core/Sessions/BaseSession.cs
  46. +1
    -1
      src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs
  47. +1
    -1
      src/TensorFlowNET.Core/Sessions/_FetchHandler.cs
  48. +1
    -1
      src/TensorFlowNET.Core/Sessions/_FetchMapper.cs
  49. +1
    -1
      src/TensorFlowNET.Core/Tensors/Ragged/RaggedTensor.cs
  50. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.Assign.cs
  51. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.Conversions.cs
  52. +41
    -37
      src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs
  53. +1
    -4
      src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs
  54. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.Index.cs
  55. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs
  56. +2
    -2
      src/TensorFlowNET.Core/Tensors/Tensor.Value.cs
  57. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensor.cs
  58. +2
    -2
      src/TensorFlowNET.Core/Tensors/TensorConverter.cs
  59. +1
    -1
      src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs
  60. +1
    -1
      src/TensorFlowNET.Core/Tensors/TensorShape.cs
  61. +1
    -1
      src/TensorFlowNET.Core/Tensors/Tensors.cs
  62. +1
    -1
      src/TensorFlowNET.Core/Tensors/c_api.tensor.cs
  63. +5
    -5
      src/TensorFlowNET.Core/Tensors/constant_op.cs
  64. +2
    -2
      src/TensorFlowNET.Core/Tensors/dtypes.cs
  65. +20
    -12
      src/TensorFlowNET.Core/Tensors/tensor_util.cs
  66. +1
    -1
      src/TensorFlowNET.Core/Training/Saving/Saver.cs
  67. +1
    -1
      src/TensorFlowNET.Core/Util/nest.py.cs
  68. +1
    -1
      src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs
  69. +1
    -1
      src/TensorFlowNET.Core/Variables/IVariableV1.cs
  70. +1
    -1
      src/TensorFlowNET.Core/Variables/RefVariable.cs
  71. +1
    -1
      src/TensorFlowNET.Core/Variables/ResourceVariable.Index.cs
  72. +1
    -1
      src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs
  73. +10
    -1
      src/TensorFlowNET.Core/ops.cs
  74. +1
    -1
      src/TensorFlowNET.Keras/BackendImpl.cs
  75. +1
    -1
      src/TensorFlowNET.Keras/Datasets/Cifar10.cs
  76. +1
    -1
      src/TensorFlowNET.Keras/Datasets/DatasetPass.cs
  77. +1
    -1
      src/TensorFlowNET.Keras/Datasets/Imdb.cs
  78. +1
    -1
      src/TensorFlowNET.Keras/Datasets/MNIST.cs
  79. +1
    -1
      src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs
  80. +1
    -1
      src/TensorFlowNET.Keras/Engine/Model.Fit.cs
  81. +1
    -1
      src/TensorFlowNET.Keras/Engine/Model.Predict.cs
  82. +1
    -1
      src/TensorFlowNET.Keras/Engine/Model.Training.cs
  83. +1
    -1
      src/TensorFlowNET.Keras/Layers/LayersApi.Merging.cs
  84. +1
    -1
      src/TensorFlowNET.Keras/Layers/LayersApi.Reshaping.cs
  85. +1
    -1
      src/TensorFlowNET.Keras/Layers/LayersApi.cs
  86. +1
    -1
      src/TensorFlowNET.Keras/Layers/Reshaping/ZeroPadding2D.cs
  87. +1
    -1
      src/TensorFlowNET.Keras/Layers/TensorFlowOpLayer.cs
  88. +1
    -1
      src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs
  89. +1
    -1
      src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
  90. +1
    -1
      src/TensorFlowNET.Keras/Preprocessings/Tokenizer.cs
  91. +1
    -1
      src/TensorFlowNET.Keras/Saving/hdf5_format.cs
  92. +1
    -1
      src/TensorFlowNET.Keras/Sequence.cs
  93. +1
    -1
      src/TensorFlowNET.Keras/Utils/base_layer_utils.cs
  94. +1
    -1
      src/TensorFlowNET.Keras/Utils/layer_utils.cs
  95. +1
    -1
      src/TensorFlowNET.Keras/Utils/np_utils.cs
  96. +1
    -1
      src/TensorFlowNET.Text/Tokenizers/WhitespaceTokenizer.cs
  97. +1
    -1
      src/TensorFlowNet.Benchmarks/Crash/RepeatDataSetCrash.cs
  98. +1
    -1
      src/TensorFlowNet.Benchmarks/Leak/GpuLeakByCNN.cs
  99. +1
    -1
      test/TensorFlowNET.Keras.UnitTest/Layers/ActivationTest.cs
  100. +1
    -1
      test/TensorFlowNET.Keras.UnitTest/Layers/CosineSimilarity.Test.cs

+ 1
- 1
src/TensorFlowNET.Console/MemoryBasicTest.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine.DataAdapters;


+ 1
- 1
src/TensorFlowNET.Console/MemoryFuncGraphTest.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;


+ 1
- 1
src/TensorFlowNET.Console/MemoryKerasTest.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using static Tensorflow.Binding;
using static Tensorflow.KerasApi;


+ 1
- 1
src/TensorFlowNET.Console/MemoryMonitor.cs View File

@@ -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;



+ 1
- 1
src/TensorFlowNET.Core/APIs/tf.array.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;


+ 29
- 0
src/TensorFlowNET.Core/APIs/tf.numpy.cs View File

@@ -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
{
/// <summary>
/// NumPy API on TensorFlow
/// https://www.tensorflow.org/api_docs/python/tf/experimental/numpy
/// </summary>
public NumPyImpl numpy => new NumPyImpl();
}
}

+ 4
- 1
src/TensorFlowNET.Core/Binding.Util.cs View File

@@ -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);



+ 1
- 1
src/TensorFlowNET.Core/Data/DataSetBase.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Data/DatasetManager.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Collections.Generic;
using Tensorflow.Data;



+ 1
- 1
src/TensorFlowNET.Core/Data/Datasets.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Data/IDataSet.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Data/MnistDataSet.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Diagnostics;



+ 1
- 1
src/TensorFlowNET.Core/Data/MnistModelLoader.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.IO;
using System.Threading.Tasks;


+ 1
- 1
src/TensorFlowNET.Core/Data/TensorDataset.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;



+ 1
- 1
src/TensorFlowNET.Core/Data/TensorSliceDataset.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;



+ 1
- 1
src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Linq;
using static Tensorflow.Binding;


+ 1
- 1
src/TensorFlowNET.Core/Framework/graph_util_impl.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Core/Framework/tensor_shape.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Linq;
using System.Text;


+ 1
- 1
src/TensorFlowNET.Core/Gradients/array_grad.cs View File

@@ -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


+ 1
- 1
src/TensorFlowNET.Core/Gradients/math_grad.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Linq;
using Tensorflow.Eager;


+ 1
- 1
src/TensorFlowNET.Core/Interfaces/ITensorOrOperation.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Keras/ArgsDefinition/Reshaping/ZeroPadding2DArgs.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow.Keras.ArgsDefinition
{


+ 1
- 1
src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Collections.Generic;

namespace Tensorflow.Keras.ArgsDefinition


+ 71
- 0
src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.Creation.cs View File

@@ -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>(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>(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]));
}
}
}

+ 10
- 0
src/TensorFlowNET.Core/NumPy/Implementation/NumPyImpl.cs View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.NumPy
{
public partial class NumPyImpl
{
}
}

+ 1
- 1
src/TensorFlowNET.Core/Numpy/IMemoryBlock.cs View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public interface IMemoryBlock
{


+ 1
- 1
src/TensorFlowNET.Core/Numpy/InfoOf.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public class InfoOf<T>
{


+ 1
- 1
src/TensorFlowNET.Core/Numpy/IteratorType.cs View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public enum IteratorType
{


+ 1
- 1
src/TensorFlowNET.Core/Numpy/NDArray.Creation.cs View File

@@ -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
{


+ 4
- 2
src/TensorFlowNET.Core/Numpy/NDArray.cs View File

@@ -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()


+ 1
- 1
src/TensorFlowNET.Core/Numpy/NDIterator.Generic.cs View File

@@ -3,7 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public partial class NDIterator<TOut> : NDIterator, IEnumerable<TOut>, IDisposable where TOut : unmanaged
{


+ 1
- 1
src/TensorFlowNET.Core/Numpy/NDIterator.cs View File

@@ -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<T>() where T : unmanaged;



+ 1
- 1
src/TensorFlowNET.Core/Numpy/NpzDictionary.cs View File

@@ -6,7 +6,7 @@ using System.IO.Compression;
using System.Linq;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public class NpzDictionary<T> : IDisposable, IReadOnlyDictionary<string, T>, ICollection<T>
where T : class,


+ 14
- 10
src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs View File

@@ -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>(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<T>(Shape shape, T fill_value)
=> new NDArray(tf.fill(tf.constant(shape), fill_value));

public static NDArray linspace<T>(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>(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<T>(Shape shape, T fill_value)
=> new NDArray(tf.fill(tf.constant(shape), fill_value));
}
}

+ 1
- 1
src/TensorFlowNET.Core/Numpy/Numpy.cs View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public partial class np
{


+ 1
- 1
src/TensorFlowNET.Core/Numpy/NumpyDType.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
/// <summary>
/// Represents all available types in numpy.


+ 1
- 1
src/TensorFlowNET.Core/Numpy/Shape.cs View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
public class Shape
{


+ 1
- 1
src/TensorFlowNET.Core/Numpy/Slice.cs View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Tensorflow.Numpy
namespace Tensorflow.NumPy
{
/// <summary> <br></br>
/// NDArray can be indexed using slicing <br></br>


+ 1
- 1
src/TensorFlowNET.Core/Operations/NnOps/rnn.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Core/Operations/Operation.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 44
- 7
src/TensorFlowNET.Core/Operations/array_ops.cs View File

@@ -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>(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<object> list_or_tuple)
private static TF_DataType _get_dtype_from_nested_lists<T>(IEnumerable<T> list_or_tuple)
{
TF_DataType dtype = TF_DataType.DtInvalid;

@@ -223,6 +223,9 @@ namespace Tensorflow
case Tensor t:
dtype = t.dtype.as_base_dtype();
break;
case NDArray t:
dtype = t.dtype.as_tf_dtype();
break;
}

if (dtype != TF_DataType.DtInvalid)
@@ -574,7 +577,7 @@ namespace Tensorflow
public static Tensor shape_v2(Tensor input, string name = null, TF_DataType out_type = TF_DataType.TF_INT32)
=> shape_internal(input, name, optimize: true, out_type: out_type);

public static Tensor size(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
public static Tensor size<T>(T input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
=> size_internal(input, name, optimize: optimize, out_type: out_type);

public static Tensor shape_internal(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
@@ -597,7 +600,7 @@ namespace Tensorflow
});
}

private static Tensor size_internal(Tensor input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
private static Tensor size_internal<T>(T input, string name = null, bool optimize = true, TF_DataType out_type = TF_DataType.TF_INT32)
{
return tf_with(ops.name_scope(name, "Size", new { input }), scope =>
{
@@ -613,7 +616,7 @@ namespace Tensorflow
}
}

return gen_array_ops.size(input, name: name, out_type: out_type);
return gen_array_ops.size(input_tensor, name: name, out_type: out_type);
});
}

@@ -777,7 +780,7 @@ namespace Tensorflow
int k = 0,
int num_rows = -1,
int num_cols = -1,
float padding_value = 0,
double padding_value = 0,
string align = "RIGHT_LEFT")
=> tf.Context.ExecuteOp("MatrixDiagV3", name,
new ExecuteOpArgs(diagonal, k, num_rows, num_cols, padding_value)
@@ -791,6 +794,40 @@ namespace Tensorflow
=> tf.Context.ExecuteOp("MatrixSetDiagV3", name, new ExecuteOpArgs(input, diagonal, k)
.SetAttributes(new { align }));

public static Tensor[] meshgrid<T>(T[] array, bool copy = true, bool sparse = false, string indexing = "xy")
{
return tf_with(ops.name_scope(null, "meshgrid", array), scope =>
{
var ndim = array.Length;
var s0 = range(ndim).Select(x => 1).ToArray();

var output = new List<Tensor>();
foreach (var (i, x) in enumerate(array))
{
var shape = s0[..i].concat(new[] { -1 }).concat(s0[(i + 1)..]);
output.add(reshape(stack(x), shape));
}

// Create parameters for broadcasting each tensor to the full size
var shapes = array.Select(x => size(x)).ToArray();
var output_dtype = _get_dtype_from_nested_lists(array).as_base_dtype();
if (indexing == "xy" && ndim > 1)
{
output[0] = reshape(output[0], new[] { 1, -1 }.concat(range(ndim - 2).Select(x => 1).ToArray()));
output[1] = reshape(output[1], new[] { -1, 1 }.concat(range(ndim - 2).Select(x => 1).ToArray()));
(shapes[0], shapes[1]) = (shapes[1], shapes[0]);
}

if(sparse)
return output.ToArray();
else
{
var mult_fact = ones(shapes, output_dtype);
return output.Select(x => x * mult_fact).ToArray();
}
});
}

/// <summary>
/// Computes the shape of a broadcast given symbolic shapes.
/// When shape_x and shape_y are Tensors representing shapes(i.e.the result of


+ 50
- 5
src/TensorFlowNET.Core/Operations/math_ops.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -430,6 +430,42 @@ namespace Tensorflow
public static Tensor lgamma(Tensor x, string name = null)
=> gen_math_ops.lgamma(x, name: name);

public static Tensor linspace(Tensor start, Tensor stop, Tensor num, string name = null, int axis = 0)
{
return tf_with(ops.name_scope(name, "linspace", new { start, stop }), scope =>
{
var expanded_start = array_ops.expand_dims(start, axis: axis);
var expanded_stop = array_ops.expand_dims(stop, axis: axis);
var shape = array_ops.shape(expanded_start);
var ndims = array_ops.shape(shape)[0];

var axis_tensor = array_ops.where_v2(constant_op.constant(axis >= 0), x: axis, y: ndims + axis);

// The purpose is to avoid having negative values when repeating.
var num_fill = gen_math_ops.maximum(num - 2, 0);
var n_steps = gen_math_ops.maximum(num - 1, 1);
var delta = (expanded_stop - expanded_start) / cast(n_steps, expanded_stop.dtype);

var range_end = array_ops.where_v2(num >= 0, n_steps, -1);
var desired_range = cast(range(1, range_end, dtype: dtypes.int64), delta.dtype);
var mask = gen_math_ops.equal(axis, range(ndims));
var desired_range_shape = array_ops.where_v2(mask, num_fill, 1);
desired_range = array_ops.reshape(desired_range, desired_range_shape);
var res = expanded_start + delta * desired_range;

// Add the start and endpoints to the result, and slice out the desired
// portion.
var all_tensors = new[] { expanded_start, res, expanded_stop };
var concatenated = array_ops.concat(all_tensors, axis: axis);
var begin = array_ops.zeros_like(shape);
var size = array_ops.where_v2(mask, num, shape);

return array_ops.slice(concatenated, begin, size);
});

throw new NotImplementedException("");
}

/// <summary>
/// Helper function for reduction ops.
/// </summary>
@@ -725,15 +761,24 @@ namespace Tensorflow
start = 0;
}

if (dtype == TF_DataType.DtInvalid)
{
if (limit is Tensor tensor)
dtype = tensor.dtype;
else
dtype = limit.GetType().as_tf_dtype();
}

if (delta == null)
{
if (limit is int)
if (dtype == TF_DataType.TF_INT32)
delta = 1;
else if (limit is long)
else if (dtype == TF_DataType.TF_INT64)
delta = 1L;
else if (limit is float)
else if (dtype == TF_DataType.TF_FLOAT)
delta = 1.0f;
else if (limit is double)
else if (dtype == TF_DataType.TF_DOUBLE)
delta = 1.0d;
else
delta = 1;


+ 1
- 1
src/TensorFlowNET.Core/Operations/nn_impl.py.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using Tensorflow.Operations;
using static Tensorflow.Binding;



+ 1
- 1
src/TensorFlowNET.Core/Operations/string_ops.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using Tensorflow.Framework;
using static Tensorflow.Binding;



+ 1
- 1
src/TensorFlowNET.Core/Sessions/BaseSession.cs View File

@@ -15,7 +15,7 @@
******************************************************************************/

using Google.Protobuf;
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Collections.Generic;


+ 1
- 1
src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;



+ 1
- 1
src/TensorFlowNET.Core/Sessions/_FetchHandler.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;



+ 1
- 1
src/TensorFlowNET.Core/Sessions/_FetchMapper.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Collections.Generic;

namespace Tensorflow


+ 1
- 1
src/TensorFlowNET.Core/Tensors/Ragged/RaggedTensor.cs View File

@@ -20,7 +20,7 @@ using System.Text;
using System.Linq;
using Tensorflow.Framework;
using static Tensorflow.Binding;
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensor.Assign.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensor.Conversions.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;


+ 41
- 37
src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -70,11 +70,15 @@ namespace Tensorflow

unsafe void InitTensor(Array array, Shape shape)
{
var dtype = array.GetType().GetElementType().as_dtype();
var dtype = array.GetType().GetElementType().as_tf_dtype();
var length = (ulong)(array.Length * dtype.get_datatype_size());

switch (array)
{
case bool[] val:
fixed (void* addr = &val[0])
_handle = TF_NewTensor(shape, dtype, addr, length);
break;
case int[] val:
fixed (void* addr = &val[0])
_handle = TF_NewTensor(shape, dtype, addr, length);
@@ -150,7 +154,7 @@ namespace Tensorflow
/// </summary>
public Tensor(sbyte[] data, TF_DataType? dType = null)
{
_handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(sbyte)), new long[] { data.Length }, data, sizeof(sbyte));
_handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(sbyte)), new long[] { data.Length }, data, sizeof(sbyte));
}

/// <summary>
@@ -158,7 +162,7 @@ namespace Tensorflow
/// </summary>
public Tensor(sbyte[] data, long[] shape, TF_DataType? dType = null)
{
_handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(sbyte)), shape, data, sizeof(sbyte));
_handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(sbyte)), shape, data, sizeof(sbyte));
}

/// <summary>
@@ -166,7 +170,7 @@ namespace Tensorflow
/// </summary>
public unsafe Tensor(sbyte value, TF_DataType? dType = null)
{
_handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(sbyte)), dims: new long[0], num_dims: 0, len: sizeof(sbyte));
_handle = TF_AllocateTensor(dType ?? dtypes.as_tf_dtype(typeof(sbyte)), dims: new long[0], num_dims: 0, len: sizeof(sbyte));
*(sbyte*)TF_TensorData(_handle) = value;
AllocationType = AllocationType.Tensorflow;
}
@@ -176,7 +180,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -184,12 +188,12 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -197,7 +201,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -215,7 +219,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -223,7 +227,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -241,7 +245,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -249,7 +253,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -267,7 +271,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -275,7 +279,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -293,7 +297,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -301,7 +305,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -319,7 +323,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -327,7 +331,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -345,7 +349,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -353,7 +357,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -371,7 +375,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -379,7 +383,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
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
/// </summary>
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));
}

/// <summary>
@@ -415,7 +419,7 @@ namespace Tensorflow
/// </summary>
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));
}

/// <summary>
@@ -423,7 +427,7 @@ namespace Tensorflow
/// </summary>
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
/// </summary>
public Tensor(Complex[] data, TF_DataType? dType = null)
{
_handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(Complex)), new long[] { data.Length }, data, Marshal.SizeOf<Complex>());
_handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(Complex)), new long[] { data.Length }, data, Marshal.SizeOf<Complex>());
}

/// <summary>
@@ -441,7 +445,7 @@ namespace Tensorflow
/// </summary>
public Tensor(Complex[] data, long[] shape, TF_DataType? dType = null)
{
_handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(Complex)), shape, data, Marshal.SizeOf<Complex>());
_handle = CreateTensorFromArray(dType ?? dtypes.as_tf_dtype(typeof(Complex)), shape, data, Marshal.SizeOf<Complex>());
}

/// <summary>
@@ -449,7 +453,7 @@ namespace Tensorflow
/// </summary>
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;
}


+ 1
- 4
src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs View File

@@ -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);
}
}

+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensor.Index.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Numerics;


+ 2
- 2
src/TensorFlowNET.Core/Tensors/Tensor.Value.cs View File

@@ -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<T>() 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?
{


+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensor.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;


+ 2
- 2
src/TensorFlowNET.Core/Tensors/TensorConverter.cs View File

@@ -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);



+ 1
- 1
src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Tensors/TensorShape.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;


+ 1
- 1
src/TensorFlowNET.Core/Tensors/Tensors.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Collections.Generic;


+ 1
- 1
src/TensorFlowNET.Core/Tensors/c_api.tensor.cs View File

@@ -17,7 +17,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 5
- 5
src/TensorFlowNET.Core/Tensors/constant_op.cs View File

@@ -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:


+ 2
- 2
src/TensorFlowNET.Core/Tensors/dtypes.cs View File

@@ -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
/// <param name="dtype"></param>
/// <returns></returns>
/// <exception cref="ArgumentException">When <paramref name="type"/> has no equivalent <see cref="TF_DataType"/></exception>
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)
{


+ 20
- 12
src/TensorFlowNET.Core/Tensors/tensor_util.cs View File

@@ -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 "<unprintable>";
}
else if (dtype == TF_DataType.TF_BOOL)
{
var array = tensor.ToArray<bool>();
return DisplayArrayAsString(array, tensor.shape);
}
else if (dtype == TF_DataType.TF_INT32)
{
var array = tensor.ToArray<int>();
return DisplayArrayAsString(array);
return DisplayArrayAsString(array, tensor.shape);
}
else if (dtype == TF_DataType.TF_INT64)
{
var array = tensor.ToArray<long>();
return DisplayArrayAsString(array);
return DisplayArrayAsString(array, tensor.shape);
}
else if (dtype == TF_DataType.TF_FLOAT)
{
var array = tensor.ToArray<float>();
return DisplayArrayAsString(array);
return DisplayArrayAsString(array, tensor.shape);
}
else if(dtype == TF_DataType.TF_DOUBLE)
{
var array = tensor.ToArray<double>();
return DisplayArrayAsString(array);
return DisplayArrayAsString(array, tensor.shape);
}
else
{
var array = tensor.ToArray<byte>();
return DisplayArrayAsString(array);
return DisplayArrayAsString(array, tensor.shape);
}
}

static string DisplayArrayAsString<T>(T[] array)
static string DisplayArrayAsString<T>(T[] array, Shape shape)
{
if (shape.ndim == 0)
return array[0].ToString();

var display = "[";
if (array.Length < 10)
display += string.Join(", ", array);


+ 1
- 1
src/TensorFlowNET.Core/Training/Saving/Saver.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.IO;


+ 1
- 1
src/TensorFlowNET.Core/Util/nest.py.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections;
using System.Collections.Generic;


+ 1
- 1
src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using Tensorflow.Eager;
using Tensorflow.Variables;


+ 1
- 1
src/TensorFlowNET.Core/Variables/IVariableV1.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 1
- 1
src/TensorFlowNET.Core/Variables/RefVariable.cs View File

@@ -15,7 +15,7 @@
******************************************************************************/

using Google.Protobuf;
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Core/Variables/ResourceVariable.Index.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;


+ 1
- 1
src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow
{


+ 10
- 1
src/TensorFlowNET.Core/ops.cs View File

@@ -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
{


+ 1
- 1
src/TensorFlowNET.Keras/BackendImpl.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Linq;
using System.Collections.Generic;


+ 1
- 1
src/TensorFlowNET.Keras/Datasets/Cifar10.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.IO;


+ 1
- 1
src/TensorFlowNET.Keras/Datasets/DatasetPass.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow.Keras.Datasets
{


+ 1
- 1
src/TensorFlowNET.Keras/Datasets/Imdb.cs View File

@@ -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


+ 1
- 1
src/TensorFlowNET.Keras/Datasets/MNIST.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.IO;
using Tensorflow.Keras.Utils;


+ 1
- 1
src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Engine/Model.Fit.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Engine/Model.Predict.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Engine/Model.Training.cs View File

@@ -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


+ 1
- 1
src/TensorFlowNET.Keras/Layers/LayersApi.Merging.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;


+ 1
- 1
src/TensorFlowNET.Keras/Layers/LayersApi.Reshaping.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;


+ 1
- 1
src/TensorFlowNET.Keras/Layers/LayersApi.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System.Collections.Generic;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;


+ 1
- 1
src/TensorFlowNET.Keras/Layers/Reshaping/ZeroPadding2D.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using Tensorflow.Keras.ArgsDefinition;
using Tensorflow.Keras.Engine;
using Tensorflow.Keras.Utils;


+ 1
- 1
src/TensorFlowNET.Keras/Layers/TensorFlowOpLayer.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Preprocessings/DatasetUtils.index_directory.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.IO;


+ 1
- 1
src/TensorFlowNET.Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs View File

@@ -1,6 +1,6 @@
using static Tensorflow.KerasApi;
using static Tensorflow.Binding;
using Tensorflow.Numpy;
using Tensorflow.NumPy;

namespace Tensorflow.Keras
{


+ 1
- 1
src/TensorFlowNET.Keras/Preprocessings/Tokenizer.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using Serilog.Debugging;
using System;
using System.Collections.Generic;


+ 1
- 1
src/TensorFlowNET.Keras/Saving/hdf5_format.cs View File

@@ -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;


+ 1
- 1
src/TensorFlowNET.Keras/Sequence.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Utils/base_layer_utils.cs View File

@@ -14,7 +14,7 @@
limitations under the License.
******************************************************************************/

using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Utils/layer_utils.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Linq;


+ 1
- 1
src/TensorFlowNET.Keras/Utils/np_utils.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;


+ 1
- 1
src/TensorFlowNET.Text/Tokenizers/WhitespaceTokenizer.cs View File

@@ -1,4 +1,4 @@
using Tensorflow.Numpy;
using Tensorflow.NumPy;
using System;
using System.Collections.Generic;
using System.Text;


+ 1
- 1
src/TensorFlowNet.Benchmarks/Crash/RepeatDataSetCrash.cs View File

@@ -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;



+ 1
- 1
src/TensorFlowNet.Benchmarks/Leak/GpuLeakByCNN.cs View File

@@ -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;


+ 1
- 1
test/TensorFlowNET.Keras.UnitTest/Layers/ActivationTest.cs View File

@@ -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;



+ 1
- 1
test/TensorFlowNET.Keras.UnitTest/Layers/CosineSimilarity.Test.cs View File

@@ -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;


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save