Skip to content

Commit 8350969

Browse files
BanycOceania2018
authored andcommitted
Add test case for tf.transpose
1 parent c01b4dd commit 8350969

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/TensorFlowNET.UnitTest/ManagedAPI/TensorOperate.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ namespace TensorFlowNET.UnitTest.ManagedAPI
88
[TestClass]
99
public class TensorOperate
1010
{
11-
[TestMethod]
11+
[TestMethod, Ignore]
1212
public void TransposeTest()
1313
{
14+
// https://www.tensorflow.org/api_docs/python/tf/transpose#for_example_2
15+
var x = tf.constant(new int[,] {
16+
{ 1, 2, 3 },
17+
{ 4, 5, 6 }
18+
});
19+
var transpose_x = tf.transpose(x);
20+
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 1, 4 }, transpose_x[0].numpy().ToArray<int>()));
21+
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 2, 5 }, transpose_x[1].numpy().ToArray<int>()));
22+
Assert.IsTrue(Enumerable.SequenceEqual(new int[] { 3, 6 }, transpose_x[2].numpy().ToArray<int>()));
23+
1424
var a = tf.constant(np.array(new[, , ,] { { { { 1, 11, 2, 22 } }, { { 3, 33, 4, 44 } } },
1525
{ { { 5, 55, 6, 66 } }, { { 7, 77, 8, 88 } } } }));
1626
var b = tf.transpose(a, new[] { 3, 1, 2, 0 });

0 commit comments

Comments
 (0)