From 01e8205f888db08d546199766b9dbf17837d4d9a Mon Sep 17 00:00:00 2001 From: pepure Date: Tue, 18 Aug 2020 19:47:08 +0800 Subject: [PATCH] tf.data.Dataset.from_tensor_slices iteration times bug --- .../TF_API/tfdata_test.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/TensorFlowNET.UnitTest/TF_API/tfdata_test.cs diff --git a/test/TensorFlowNET.UnitTest/TF_API/tfdata_test.cs b/test/TensorFlowNET.UnitTest/TF_API/tfdata_test.cs new file mode 100644 index 00000000..e8147b6e --- /dev/null +++ b/test/TensorFlowNET.UnitTest/TF_API/tfdata_test.cs @@ -0,0 +1,27 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Tensorflow; +using static Tensorflow.Binding; + +namespace TensorFlowNET.UnitTest.TF_API +{ + [TestClass] + public class tfdata_test + { + [TestMethod] + public void CreateFromTensor() + { + var X = tf.constant(new[] { 2013, 2014, 2015, 2016, 2017 }); + var Y = tf.constant(new[] { 12000, 14000, 15000, 16500, 17500 }); + + var dataset = tf.data.Dataset.from_tensor_slices(X, Y); + int n = 0; + foreach (var (item_x, item_y) in dataset) + { + print($"x:{item_x.numpy()},y:{item_y.numpy()}"); + n += 1; + } + Assert.AreEqual(5, n); + } + + } +}