You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

tfdata_test.cs 745 B

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