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.

ConstantTest.cs 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using NumSharp.Core;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using Tensorflow;
  7. namespace TensorFlowNET.UnitTest
  8. {
  9. [TestClass]
  10. public class ConstantTest
  11. {
  12. Tensor tensor;
  13. [TestMethod]
  14. public void ScalarConst()
  15. {
  16. tensor = tf.constant(8); // int
  17. tensor = tf.constant(6.0f); // float
  18. tensor = tf.constant(6.0); // double
  19. }
  20. [TestMethod]
  21. public void StringConst()
  22. {
  23. tensor = tf.constant("Elephant");
  24. }
  25. [TestMethod]
  26. public void NDimConst()
  27. {
  28. var nd = np.array(new int[][]
  29. {
  30. new int[]{ 1, 2, 3 },
  31. new int[]{ 4, 5, 6 }
  32. });
  33. tensor = tf.constant(nd);
  34. }
  35. }
  36. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。