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