diff --git a/test/TensorFlowNET.Examples/BasicEagerApi.cs b/test/TensorFlowNET.Examples/BasicEagerApi.cs index 3440d174..0c4f4bbf 100644 --- a/test/TensorFlowNET.Examples/BasicEagerApi.cs +++ b/test/TensorFlowNET.Examples/BasicEagerApi.cs @@ -11,7 +11,9 @@ namespace TensorFlowNET.Examples /// public class BasicEagerApi : IExample { + public int Priority => 100; public bool Enabled => false; + public string Name => "Basic Eager"; private Tensor a, b, c, d; diff --git a/test/TensorFlowNET.Examples/BasicOperations.cs b/test/TensorFlowNET.Examples/BasicOperations.cs index 829ecc9a..d9025cfe 100644 --- a/test/TensorFlowNET.Examples/BasicOperations.cs +++ b/test/TensorFlowNET.Examples/BasicOperations.cs @@ -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() diff --git a/test/TensorFlowNET.Examples/HelloWorld.cs b/test/TensorFlowNET.Examples/HelloWorld.cs index f9b2baa8..b0ddeb34 100644 --- a/test/TensorFlowNET.Examples/HelloWorld.cs +++ b/test/TensorFlowNET.Examples/HelloWorld.cs @@ -11,7 +11,10 @@ namespace TensorFlowNET.Examples /// 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 diff --git a/test/TensorFlowNET.Examples/IExample.cs b/test/TensorFlowNET.Examples/IExample.cs index b5c47b76..c8320810 100644 --- a/test/TensorFlowNET.Examples/IExample.cs +++ b/test/TensorFlowNET.Examples/IExample.cs @@ -10,8 +10,25 @@ namespace TensorFlowNET.Examples /// public interface IExample { + /// + /// running order + /// + int Priority { get; } + /// + /// True to run example + /// bool Enabled { get; } + + string Name { get; } + + /// + /// Build dataflow graph, train and predict + /// + /// bool Run(); + /// + /// Prepare dataset + /// void PrepareData(); } } diff --git a/test/TensorFlowNET.Examples/ImageRecognition.cs b/test/TensorFlowNET.Examples/ImageRecognition.cs index 58e4bde3..101ff836 100644 --- a/test/TensorFlowNET.Examples/ImageRecognition.cs +++ b/test/TensorFlowNET.Examples/ImageRecognition.cs @@ -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"; diff --git a/test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs b/test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs index bfea1922..99581d4f 100644 --- a/test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs +++ b/test/TensorFlowNET.Examples/InceptionArchGoogLeNet.cs @@ -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"; diff --git a/test/TensorFlowNET.Examples/LinearRegression.cs b/test/TensorFlowNET.Examples/LinearRegression.cs index efd9dc7e..7f550c68 100644 --- a/test/TensorFlowNET.Examples/LinearRegression.cs +++ b/test/TensorFlowNET.Examples/LinearRegression.cs @@ -12,7 +12,9 @@ namespace TensorFlowNET.Examples /// public class LinearRegression : Python, IExample { + public int Priority => 3; public bool Enabled => true; + public string Name => "Linear Regression"; NumPyRandom rng = np.random; diff --git a/test/TensorFlowNET.Examples/LogisticRegression.cs b/test/TensorFlowNET.Examples/LogisticRegression.cs index 0d994fd3..7b5925ef 100644 --- a/test/TensorFlowNET.Examples/LogisticRegression.cs +++ b/test/TensorFlowNET.Examples/LogisticRegression.cs @@ -17,7 +17,10 @@ namespace TensorFlowNET.Examples /// 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; diff --git a/test/TensorFlowNET.Examples/MetaGraph.cs b/test/TensorFlowNET.Examples/MetaGraph.cs index 52f14933..d05386f2 100644 --- a/test/TensorFlowNET.Examples/MetaGraph.cs +++ b/test/TensorFlowNET.Examples/MetaGraph.cs @@ -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() { diff --git a/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs b/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs index 8fa3ec67..750bbb90 100644 --- a/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs +++ b/test/TensorFlowNET.Examples/NaiveBayesClassifier.cs @@ -12,7 +12,10 @@ namespace TensorFlowNET.Examples /// 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() { diff --git a/test/TensorFlowNET.Examples/NamedEntityRecognition.cs b/test/TensorFlowNET.Examples/NamedEntityRecognition.cs index 9737354d..a6c7f2f1 100644 --- a/test/TensorFlowNET.Examples/NamedEntityRecognition.cs +++ b/test/TensorFlowNET.Examples/NamedEntityRecognition.cs @@ -10,7 +10,10 @@ namespace TensorFlowNET.Examples /// public class NamedEntityRecognition : Python, IExample { + public int Priority => 100; public bool Enabled => false; + public string Name => "NER"; + public bool Run() { throw new NotImplementedException(); diff --git a/test/TensorFlowNET.Examples/Program.cs b/test/TensorFlowNET.Examples/Program.cs index befab612..64ec3449 100644 --- a/test/TensorFlowNET.Examples/Program.cs +++ b/test/TensorFlowNET.Examples/Program.cs @@ -15,32 +15,35 @@ namespace TensorFlowNET.Examples var errors = new List(); var success = new List(); var disabled = new List(); + 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)); diff --git a/test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs b/test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs index b5d04627..a1251750 100644 --- a/test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs +++ b/test/TensorFlowNET.Examples/TextClassification/TextClassificationTrain.cs @@ -15,7 +15,10 @@ namespace TensorFlowNET.Examples.CnnTextClassification /// 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"; diff --git a/test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs b/test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs index e164ffbf..9068b17a 100644 --- a/test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs +++ b/test/TensorFlowNET.Examples/TextClassification/TextClassificationWithMovieReviews.cs @@ -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;