Browse Source

added all examples to the unit testing suite

tags/v0.9
Meinrad Recheis 6 years ago
parent
commit
4bc97cd478
18 changed files with 125 additions and 18 deletions
  1. +10
    -3
      src/TensorFlowNET.Core/Python.cs
  2. +1
    -1
      test/TensorFlowNET.Examples/BasicEagerApi.cs
  3. +1
    -1
      test/TensorFlowNET.Examples/BasicOperations.cs
  4. +1
    -1
      test/TensorFlowNET.Examples/HelloWorld.cs
  5. +1
    -1
      test/TensorFlowNET.Examples/IExample.cs
  6. +1
    -1
      test/TensorFlowNET.Examples/ImageRecognition.cs
  7. +1
    -1
      test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs
  8. +1
    -1
      test/TensorFlowNET.Examples/KMeansClustering.cs
  9. +1
    -1
      test/TensorFlowNET.Examples/LinearRegression.cs
  10. +1
    -1
      test/TensorFlowNET.Examples/LogisticRegression.cs
  11. +1
    -1
      test/TensorFlowNET.Examples/MetaGraph.cs
  12. +1
    -1
      test/TensorFlowNET.Examples/NaiveBayesClassifier.cs
  13. +1
    -1
      test/TensorFlowNET.Examples/NamedEntityRecognition.cs
  14. +1
    -1
      test/TensorFlowNET.Examples/NearestNeighbor.cs
  15. +1
    -1
      test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs
  16. +1
    -1
      test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs
  17. +99
    -0
      test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs
  18. +1
    -0
      test/TensorFlowNET.UnitTest/TensorFlowNET.UnitTest.csproj

+ 10
- 3
src/TensorFlowNET.Core/Python.cs View File

@@ -46,7 +46,10 @@ namespace Tensorflow
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
throw ex;
#if DEBUG
Debugger.Break();
#endif
throw;
}
finally
{
@@ -65,7 +68,10 @@ namespace Tensorflow
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
throw ex;
#if DEBUG
Debugger.Break();
#endif
throw;
}
finally
{
@@ -85,8 +91,9 @@ namespace Tensorflow
{
Console.WriteLine(ex.ToString());
#if DEBUG
Debugger.Break();
Debugger.Break();
#endif
throw;
return default(TOut);
}
finally


+ 1
- 1
test/TensorFlowNET.Examples/BasicEagerApi.cs View File

@@ -12,7 +12,7 @@ namespace TensorFlowNET.Examples
public class BasicEagerApi : IExample
{
public int Priority => 100;
public bool Enabled => false;
public bool Enabled { get; set; } = false;
public string Name => "Basic Eager";

private Tensor a, b, c, d;


+ 1
- 1
test/TensorFlowNET.Examples/BasicOperations.cs View File

@@ -12,7 +12,7 @@ namespace TensorFlowNET.Examples
/// </summary>
public class BasicOperations : Python, IExample
{
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public int Priority => 2;
public string Name => "Basic Operations";



+ 1
- 1
test/TensorFlowNET.Examples/HelloWorld.cs View File

@@ -12,7 +12,7 @@ namespace TensorFlowNET.Examples
public class HelloWorld : Python, IExample
{
public int Priority => 1;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "Hello World";

public bool Run()


+ 1
- 1
test/TensorFlowNET.Examples/IExample.cs View File

@@ -17,7 +17,7 @@ namespace TensorFlowNET.Examples
/// <summary>
/// True to run example
/// </summary>
bool Enabled { get; }
bool Enabled { get; set; }

string Name { get; }



+ 1
- 1
test/TensorFlowNET.Examples/ImageRecognition.cs View File

@@ -13,7 +13,7 @@ namespace TensorFlowNET.Examples
public class ImageRecognition : Python, IExample
{
public int Priority => 7;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "Image Recognition";

string dir = "ImageRecognition";


+ 1
- 1
test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs View File

@@ -19,7 +19,7 @@ namespace TensorFlowNET.Examples
/// </summary>
public class InceptionArchGoogLeNet : Python, IExample
{
public bool Enabled => false;
public bool Enabled { get; set; } = false;
public int Priority => 100;
public string Name => "Inception Arch GoogLeNet";



+ 1
- 1
test/TensorFlowNET.Examples/KMeansClustering.cs View File

@@ -16,7 +16,7 @@ namespace TensorFlowNET.Examples
public class KMeansClustering : Python, IExample
{
public int Priority => 8;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "K-means Clustering";

Datasets mnist;


+ 1
- 1
test/TensorFlowNET.Examples/LinearRegression.cs View File

@@ -13,7 +13,7 @@ namespace TensorFlowNET.Examples
public class LinearRegression : Python, IExample
{
public int Priority => 3;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "Linear Regression";

NumPyRandom rng = np.random;


+ 1
- 1
test/TensorFlowNET.Examples/LogisticRegression.cs View File

@@ -17,7 +17,7 @@ namespace TensorFlowNET.Examples
public class LogisticRegression : Python, IExample
{
public int Priority => 4;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "Logistic Regression";

private float learning_rate = 0.01f;


+ 1
- 1
test/TensorFlowNET.Examples/MetaGraph.cs View File

@@ -10,7 +10,7 @@ namespace TensorFlowNET.Examples
public class MetaGraph : Python, IExample
{
public int Priority => 100;
public bool Enabled => false;
public bool Enabled { get; set; } = false;
public string Name => "Meta Graph";

public bool Run()


+ 1
- 1
test/TensorFlowNET.Examples/NaiveBayesClassifier.cs View File

@@ -13,7 +13,7 @@ namespace TensorFlowNET.Examples
public class NaiveBayesClassifier : Python, IExample
{
public int Priority => 6;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "Naive Bayes Classifier";

public Normal dist { get; set; }


+ 1
- 1
test/TensorFlowNET.Examples/NamedEntityRecognition.cs View File

@@ -11,7 +11,7 @@ namespace TensorFlowNET.Examples
public class NamedEntityRecognition : Python, IExample
{
public int Priority => 100;
public bool Enabled => false;
public bool Enabled { get; set; } = false;
public string Name => "NER";

public bool Run()


+ 1
- 1
test/TensorFlowNET.Examples/NearestNeighbor.cs View File

@@ -15,7 +15,7 @@ namespace TensorFlowNET.Examples
public class NearestNeighbor : Python, IExample
{
public int Priority => 5;
public bool Enabled => true;
public bool Enabled { get; set; } = true;
public string Name => "Nearest Neighbor";
Datasets mnist;
NDArray Xtr, Ytr, Xte, Yte;


+ 1
- 1
test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs View File

@@ -15,7 +15,7 @@ namespace TensorFlowNET.Examples.CnnTextClassification
public class TextClassificationTrain : Python, IExample
{
public int Priority => 100;
public bool Enabled => false;
public bool Enabled { get; set; }= false;
public string Name => "Text Classification";

private string dataDir = "text_classification";


+ 1
- 1
test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs View File

@@ -12,7 +12,7 @@ namespace TensorFlowNET.Examples
public class TextClassificationWithMovieReviews : Python, IExample
{
public int Priority => 9;
public bool Enabled => false;
public bool Enabled { get; set; } = false;
public string Name => "Movie Reviews";

string dir = "text_classification_with_movie_reviews";


+ 99
- 0
test/TensorFlowNET.UnitTest/ExamplesTests/ExamplesTest.cs View File

@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TensorFlowNET.Examples;
using TensorFlowNET.Examples.CnnTextClassification;
namespace TensorFlowNET.UnitTest.ExamplesTests
{
[TestClass]
public class ExamplesTest
{
[TestMethod]
public void BasicOperations()
{
new BasicOperations() { Enabled = true }.Run();
}
[TestMethod]
public void HelloWorld()
{
new HelloWorld() { Enabled = true }.Run();
}
[TestMethod]
public void ImageRecognition()
{
new HelloWorld() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void InceptionArchGoogLeNet()
{
new InceptionArchGoogLeNet() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void KMeansClustering()
{
new KMeansClustering() { Enabled = true }.Run();
}
[TestMethod]
public void LinearRegression()
{
new LinearRegression() { Enabled = true }.Run();
}
[TestMethod]
public void LogisticRegression()
{
new LogisticRegression() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void MetaGraph()
{
new MetaGraph() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void NaiveBayesClassifier()
{
new NaiveBayesClassifier() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void NamedEntityRecognition()
{
new NamedEntityRecognition() { Enabled = true }.Run();
}
[TestMethod]
public void NearestNeighbor()
{
new NearestNeighbor() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void TextClassificationTrain()
{
new TextClassificationTrain() { Enabled = true }.Run();
}
[Ignore]
[TestMethod]
public void TextClassificationWithMovieReviews()
{
new TextClassificationWithMovieReviews() { Enabled = true }.Run();
}
}
}

+ 1
- 0
test/TensorFlowNET.UnitTest/TensorFlowNET.UnitTest.csproj View File

@@ -23,6 +23,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\TensorFlowNET.Core\TensorFlowNET.Core.csproj" />
<ProjectReference Include="..\TensorFlowNET.Examples\TensorFlowNET.Examples.csproj" />
</ItemGroup>

</Project>

Loading…
Cancel
Save