Browse Source

tf.slice #396

tags/v0.12
Oceania2018 6 years ago
parent
commit
18f4579fd7
2 changed files with 24 additions and 0 deletions
  1. +11
    -0
      src/TensorFlowNET.Core/APIs/tf.array.cs
  2. +13
    -0
      test/TensorFlowNET.UnitTest/TensorTest.cs

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

@@ -104,6 +104,17 @@ namespace Tensorflow
public Tensor rank(Tensor input, string name = null)
=> array_ops.rank(input, name: name);

/// <summary>
/// Extracts a slice from a tensor.
/// </summary>
/// <param name="input">A `Tensor`.</param>
/// <param name="begin">An `int32` or `int64` `Tensor`.</param>
/// <param name="size">An `int32` or `int64` `Tensor`.</param>
/// <param name="name">A name for the operation (optional).</param>
/// <returns>A `Tensor` the same type as `input`.</returns>
public Tensor slice<Tb, Ts>(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);



+ 13
- 0
test/TensorFlowNET.UnitTest/TensorTest.cs View File

@@ -221,5 +221,18 @@ namespace TensorFlowNET.UnitTest
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 0, 0, 0, 0, 1 }, result[4].ToArray<int>()));
};
}

[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<int>(indices, values, dense_shape);*/
}
}
}

Loading…
Cancel
Save