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.

OperationsTest.cs 1.1 kB

6 years ago
6 years ago
6 years ago
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Tensorflow;
  6. namespace TensorFlowNET.UnitTest
  7. {
  8. [TestClass]
  9. public class OperationsTest
  10. {
  11. [TestMethod]
  12. public void constant()
  13. {
  14. var a = tf.constant(4.0f);
  15. var b = tf.constant(5.0f);
  16. var c = tf.add(a, b);
  17. using (var sess = tf.Session())
  18. {
  19. var o = sess.run(c);
  20. }
  21. }
  22. [TestMethod]
  23. public void placeholder()
  24. {
  25. var x = tf.placeholder(tf.float32);
  26. }
  27. [TestMethod]
  28. public void add()
  29. {
  30. var a = tf.placeholder(tf.float32);
  31. var b = tf.placeholder(tf.float32);
  32. var c = tf.add(a, b);
  33. using(var sess = tf.Session())
  34. {
  35. var feed_dict = new Dictionary<Tensor, object>();
  36. feed_dict.Add(a, 3.0f);
  37. feed_dict.Add(b, 2.0f);
  38. var o = sess.run(c, feed_dict);
  39. }
  40. }
  41. }
  42. }

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

Contributors (1)