diff --git a/src/TensorFlowNET.Core/APIs/tf.array.cs b/src/TensorFlowNET.Core/APIs/tf.array.cs index 4727a00f..aca13ed1 100644 --- a/src/TensorFlowNET.Core/APIs/tf.array.cs +++ b/src/TensorFlowNET.Core/APIs/tf.array.cs @@ -104,6 +104,17 @@ namespace Tensorflow public Tensor rank(Tensor input, string name = null) => array_ops.rank(input, name: name); + /// + /// Extracts a slice from a tensor. + /// + /// A `Tensor`. + /// An `int32` or `int64` `Tensor`. + /// An `int32` or `int64` `Tensor`. + /// A name for the operation (optional). + /// A `Tensor` the same type as `input`. + public Tensor slice(Tensor input, Tb[] begin, Ts[] size, string name = null) + => array_ops.slice(input, begin, size, name: name); + public Tensor squeeze(Tensor input, int[] axis = null, string name = null, int squeeze_dims = -1) => gen_array_ops.squeeze(input, axis, name); diff --git a/test/TensorFlowNET.UnitTest/TensorTest.cs b/test/TensorFlowNET.UnitTest/TensorTest.cs index 14194ac6..5f6a4b40 100644 --- a/test/TensorFlowNET.UnitTest/TensorTest.cs +++ b/test/TensorFlowNET.UnitTest/TensorTest.cs @@ -221,5 +221,18 @@ namespace TensorFlowNET.UnitTest Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 0, 0, 0, 0, 1 }, result[4].ToArray())); }; } + + [TestMethod] + public void sparse_tensor_to_dense() + { + /*int[,] dense_array = + { + { 1, 0, 0, 0, 0 }, + { 0, 1, 0, 0, 0 }, + { 0, 0, 1, 0, 0 }, + { 0, 0, 0, 1, 0 } + }; + var sparseTensor = new SparseTensor(indices, values, dense_shape);*/ + } } } \ No newline at end of file