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.

HelloWorld.cs 1.7 kB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow;
  5. using static Tensorflow.Python;
  6. namespace TensorFlowNET.Examples
  7. {
  8. /// <summary>
  9. /// Simple hello world using TensorFlow
  10. /// https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/helloworld.py
  11. /// </summary>
  12. public class HelloWorld : IExample
  13. {
  14. public bool Enabled { get; set; } = true;
  15. public string Name => "Hello World";
  16. public bool IsImportingGraph { get; set; } = false;
  17. public bool Run()
  18. {
  19. /* Create a Constant op
  20. The op is added as a node to the default graph.
  21. The value returned by the constructor represents the output
  22. of the Constant op. */
  23. var str = "Hello, TensorFlow.NET!";
  24. var hello = tf.constant(str);
  25. // Start tf session
  26. return with(tf.Session(), sess =>
  27. {
  28. // Run the op
  29. var result = sess.run(hello);
  30. Console.WriteLine(result.ToString());
  31. return result.ToString().Equals(str);
  32. });
  33. }
  34. public void PrepareData()
  35. {
  36. }
  37. public Graph ImportGraph()
  38. {
  39. throw new NotImplementedException();
  40. }
  41. public Graph BuildGraph()
  42. {
  43. throw new NotImplementedException();
  44. }
  45. public bool Train()
  46. {
  47. throw new NotImplementedException();
  48. }
  49. public bool Predict()
  50. {
  51. throw new NotImplementedException();
  52. }
  53. }
  54. }