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.

ExamplesTest.cs 3.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.VisualStudio.TestTools.UnitTesting;
  5. using Tensorflow;
  6. using TensorFlowNET.Examples;
  7. using TensorFlowNET.Examples.CnnTextClassification;
  8. namespace TensorFlowNET.ExamplesTests
  9. {
  10. [TestClass]
  11. public class ExamplesTest
  12. {
  13. [TestMethod]
  14. public void BasicOperations()
  15. {
  16. tf.Graph().as_default();
  17. new BasicOperations() { Enabled = true }.Run();
  18. }
  19. [TestMethod]
  20. public void HelloWorld()
  21. {
  22. tf.Graph().as_default();
  23. new HelloWorld() { Enabled = true }.Run();
  24. }
  25. [TestMethod]
  26. public void ImageRecognition()
  27. {
  28. tf.Graph().as_default();
  29. new HelloWorld() { Enabled = true }.Run();
  30. }
  31. [Ignore]
  32. [TestMethod]
  33. public void InceptionArchGoogLeNet()
  34. {
  35. tf.Graph().as_default();
  36. new InceptionArchGoogLeNet() { Enabled = true }.Run();
  37. }
  38. [TestMethod]
  39. public void KMeansClustering()
  40. {
  41. tf.Graph().as_default();
  42. new KMeansClustering() { Enabled = true, ImportGraph = true, train_size = 500, validation_size = 100, test_size = 100, batch_size =100 }.Run();
  43. }
  44. [TestMethod]
  45. public void LinearRegression()
  46. {
  47. tf.Graph().as_default();
  48. new LinearRegression() { Enabled = true }.Run();
  49. }
  50. [TestMethod]
  51. public void LogisticRegression()
  52. {
  53. tf.Graph().as_default();
  54. new LogisticRegression() { Enabled = true, training_epochs=10, train_size = 500, validation_size = 100, test_size = 100 }.Run();
  55. }
  56. [Ignore]
  57. [TestMethod]
  58. public void NaiveBayesClassifier()
  59. {
  60. tf.Graph().as_default();
  61. new NaiveBayesClassifier() { Enabled = false }.Run();
  62. }
  63. [Ignore]
  64. [TestMethod]
  65. public void NamedEntityRecognition()
  66. {
  67. tf.Graph().as_default();
  68. new NamedEntityRecognition() { Enabled = true }.Run();
  69. }
  70. [TestMethod]
  71. public void NearestNeighbor()
  72. {
  73. tf.Graph().as_default();
  74. new NearestNeighbor() { Enabled = true, TrainSize = 500, ValidationSize = 100, TestSize = 100 }.Run();
  75. }
  76. [Ignore]
  77. [TestMethod]
  78. public void TextClassificationTrain()
  79. {
  80. tf.Graph().as_default();
  81. new TextClassificationTrain() { Enabled = true, DataLimit=100 }.Run();
  82. }
  83. [Ignore]
  84. [TestMethod]
  85. public void TextClassificationWithMovieReviews()
  86. {
  87. tf.Graph().as_default();
  88. new BinaryTextClassification() { Enabled = true }.Run();
  89. }
  90. [TestMethod]
  91. public void NeuralNetXor()
  92. {
  93. tf.Graph().as_default();
  94. Assert.IsTrue(new NeuralNetXor() { Enabled = true, ImportGraph = false }.Run());
  95. }
  96. [TestMethod]
  97. public void NeuralNetXor_ImportedGraph()
  98. {
  99. tf.Graph().as_default();
  100. Assert.IsTrue(new NeuralNetXor() { Enabled = true, ImportGraph = true }.Run());
  101. }
  102. [TestMethod]
  103. public void ObjectDetection()
  104. {
  105. tf.Graph().as_default();
  106. Assert.IsTrue(new ObjectDetection() { Enabled = true, ImportGraph = true }.Run());
  107. }
  108. }
  109. }

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