Skip to content

Commit 01e8205

Browse files
committed
tf.data.Dataset.from_tensor_slices iteration times bug
1 parent 4053080 commit 01e8205

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Tensorflow;
3+
using static Tensorflow.Binding;
4+
5+
namespace TensorFlowNET.UnitTest.TF_API
6+
{
7+
[TestClass]
8+
public class tfdata_test
9+
{
10+
[TestMethod]
11+
public void CreateFromTensor()
12+
{
13+
var X = tf.constant(new[] { 2013, 2014, 2015, 2016, 2017 });
14+
var Y = tf.constant(new[] { 12000, 14000, 15000, 16500, 17500 });
15+
16+
var dataset = tf.data.Dataset.from_tensor_slices(X, Y);
17+
int n = 0;
18+
foreach (var (item_x, item_y) in dataset)
19+
{
20+
print($"x:{item_x.numpy()},y:{item_y.numpy()}");
21+
n += 1;
22+
}
23+
Assert.AreEqual(5, n);
24+
}
25+
26+
}
27+
}

0 commit comments

Comments
 (0)