Browse Source

Added Name and Priority to IExample interface.

tags/v0.9
Oceania2018 6 years ago
parent
commit
19f4699502
14 changed files with 61 additions and 9 deletions
  1. +2
    -0
      test/TensorFlowNET.Examples/BasicEagerApi.cs
  2. +3
    -0
      test/TensorFlowNET.Examples/BasicOperations.cs
  3. +3
    -0
      test/TensorFlowNET.Examples/HelloWorld.cs
  4. +17
    -0
      test/TensorFlowNET.Examples/IExample.cs
  5. +2
    -0
      test/TensorFlowNET.Examples/ImageRecognition.cs
  6. +3
    -0
      test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs
  7. +2
    -0
      test/TensorFlowNET.Examples/LinearRegression.cs
  8. +3
    -0
      test/TensorFlowNET.Examples/LogisticRegression.cs
  9. +2
    -0
      test/TensorFlowNET.Examples/MetaGraph.cs
  10. +3
    -0
      test/TensorFlowNET.Examples/NaiveBayesClassifier.cs
  11. +3
    -0
      test/TensorFlowNET.Examples/NamedEntityRecognition.cs
  12. +12
    -9
      test/TensorFlowNET.Examples/Program.cs
  13. +3
    -0
      test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs
  14. +3
    -0
      test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs

+ 2
- 0
test/TensorFlowNET.Examples/BasicEagerApi.cs View File

@@ -11,7 +11,9 @@ namespace TensorFlowNET.Examples
/// </summary>
public class BasicEagerApi : IExample
{
public int Priority => 100;
public bool Enabled => false;
public string Name => "Basic Eager";

private Tensor a, b, c, d;



+ 3
- 0
test/TensorFlowNET.Examples/BasicOperations.cs View File

@@ -13,6 +13,9 @@ namespace TensorFlowNET.Examples
public class BasicOperations : Python, IExample
{
public bool Enabled => true;
public int Priority => 2;
public string Name => "Basic Operations";

private Session sess;

public bool Run()


+ 3
- 0
test/TensorFlowNET.Examples/HelloWorld.cs View File

@@ -11,7 +11,10 @@ namespace TensorFlowNET.Examples
/// </summary>
public class HelloWorld : Python, IExample
{
public int Priority => 1;
public bool Enabled => true;
public string Name => "Hello World";

public bool Run()
{
/* Create a Constant op


+ 17
- 0
test/TensorFlowNET.Examples/IExample.cs View File

@@ -10,8 +10,25 @@ namespace TensorFlowNET.Examples
/// </summary>
public interface IExample
{
/// <summary>
/// running order
/// </summary>
int Priority { get; }
/// <summary>
/// True to run example
/// </summary>
bool Enabled { get; }

string Name { get; }

/// <summary>
/// Build dataflow graph, train and predict
/// </summary>
/// <returns></returns>
bool Run();
/// <summary>
/// Prepare dataset
/// </summary>
void PrepareData();
}
}

+ 2
- 0
test/TensorFlowNET.Examples/ImageRecognition.cs View File

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

string dir = "ImageRecognition";
string pbFile = "tensorflow_inception_graph.pb";


+ 3
- 0
test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs View File

@@ -20,6 +20,9 @@ namespace TensorFlowNET.Examples
public class InceptionArchGoogLeNet : Python, IExample
{
public bool Enabled => false;
public int Priority => 100;
public string Name => "Inception Arch GoogLeNet";

string dir = "label_image_data";
string pbFile = "inception_v3_2016_08_28_frozen.pb";
string labelFile = "imagenet_slim_labels.txt";


+ 2
- 0
test/TensorFlowNET.Examples/LinearRegression.cs View File

@@ -12,7 +12,9 @@ namespace TensorFlowNET.Examples
/// </summary>
public class LinearRegression : Python, IExample
{
public int Priority => 3;
public bool Enabled => true;
public string Name => "Linear Regression";

NumPyRandom rng = np.random;



+ 3
- 0
test/TensorFlowNET.Examples/LogisticRegression.cs View File

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

private float learning_rate = 0.01f;
private int training_epochs = 10;
private int batch_size = 100;


+ 2
- 0
test/TensorFlowNET.Examples/MetaGraph.cs View File

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

public bool Run()
{


+ 3
- 0
test/TensorFlowNET.Examples/NaiveBayesClassifier.cs View File

@@ -12,7 +12,10 @@ namespace TensorFlowNET.Examples
/// </summary>
public class NaiveBayesClassifier : Python, IExample
{
public int Priority => 100;
public bool Enabled => false;
public string Name => "Naive Bayes Classifier";

public Normal dist { get; set; }
public bool Run()
{


+ 3
- 0
test/TensorFlowNET.Examples/NamedEntityRecognition.cs View File

@@ -10,7 +10,10 @@ namespace TensorFlowNET.Examples
/// </summary>
public class NamedEntityRecognition : Python, IExample
{
public int Priority => 100;
public bool Enabled => false;
public string Name => "NER";

public bool Run()
{
throw new NotImplementedException();


+ 12
- 9
test/TensorFlowNET.Examples/Program.cs View File

@@ -15,32 +15,35 @@ namespace TensorFlowNET.Examples
var errors = new List<string>();
var success = new List<string>();
var disabled = new List<string>();
var examples = assembly.GetTypes()
.Where(x => x.GetInterfaces().Contains(typeof(IExample)))
.Select(x => (IExample)Activator.CreateInstance(x))
.OrderBy(x => x.Priority)
.ToArray();

foreach (Type type in assembly.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IExample))))
foreach (IExample example in examples)
{
if (args.Length > 0 && !args.Contains(type.Name))
if (args.Length > 0 && !args.Contains(example.Name))
continue;

Console.WriteLine($"{DateTime.UtcNow} Starting {type.Name}", Color.Tan);

var example = (IExample)Activator.CreateInstance(type);
Console.WriteLine($"{DateTime.UtcNow} Starting {example.Name}", Color.White);

try
{
if (example.Enabled)
if (example.Run())
success.Add(type.Name);
success.Add($"{example.Priority} {example.Name}");
else
errors.Add(type.Name);
errors.Add($"{example.Priority} {example.Name}");
else
disabled.Add(type.Name);
disabled.Add($"{example.Priority} {example.Name}");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}

Console.WriteLine($"{DateTime.UtcNow} Completed {type.Name}", Color.Tan);
Console.WriteLine($"{DateTime.UtcNow} Completed {example.Name}", Color.White);
}

success.ForEach(x => Console.WriteLine($"{x} example is OK!", Color.Green));


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

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

private string dataDir = "text_classification";
private string dataFileName = "dbpedia_csv.tar.gz";



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

@@ -11,7 +11,10 @@ namespace TensorFlowNET.Examples
{
public class TextClassificationWithMovieReviews : Python, IExample
{
public int Priority => 6;
public bool Enabled => false;
public string Name => "Movie Reviews";

string dir = "text_classification_with_movie_reviews";
string dataFile = "imdb.zip";
NDArray train_data, train_labels, test_data, test_labels;


Loading…
Cancel
Save