| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a4f03c2 commit d3724a9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -190,7 +190,7 @@ protected virtual RefVariable add_weight(string name, | |||
| 190 | 190 | var variable = _add_variable_with_custom_getter(name, | |
| 191 | 191 | shape, | |
| 192 | 192 | dtype: dtype, | |
| 193 | - getter: getter, // getter == null ? base_layer_utils.make_variable : getter, | ||
| 193 | + getter: (getter == null) ? base_layer_utils.make_variable : getter, | ||
| 194 | 194 | overwrite: true, | |
| 195 | 195 | initializer: initializer, | |
| 196 | 196 | trainable: trainable.Value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,21 @@ namespace Tensorflow.Keras.Utils | |||
| 8 | 8 | { | |
| 9 | 9 | public class base_layer_utils | |
| 10 | 10 | { | |
| 11 | + /// <summary> | ||
| 12 | + /// Adds a new variable to the layer. | ||
| 13 | + /// </summary> | ||
| 14 | + /// <param name="name"></param> | ||
| 15 | + /// <param name="shape"></param> | ||
| 16 | + /// <param name="dtype"></param> | ||
| 17 | + /// <param name="initializer"></param> | ||
| 18 | + /// <param name="trainable"></param> | ||
| 19 | + /// <returns></returns> | ||
| 20 | + public static RefVariable make_variable(string name, | ||
| 21 | + int[] shape, | ||
| 22 | + TF_DataType dtype = TF_DataType.TF_FLOAT, | ||
| 23 | + IInitializer initializer = null, | ||
| 24 | + bool trainable = true) => make_variable(name, shape, dtype, initializer, trainable, true); | ||
| 25 | + | ||
| 11 | 26 | /// <summary> | |
| 12 | 27 | /// Adds a new variable to the layer. | |
| 13 | 28 | /// </summary> | |
@@ -28,7 +43,7 @@ public static RefVariable make_variable(string name, | |||
| 28 | 43 | ||
| 29 | 44 | ops.init_scope(); | |
| 30 | 45 | ||
| 31 | - Func<Tensor> init_val = ()=> initializer.call(new TensorShape(shape), dtype: dtype); | ||
| 46 | + Func<Tensor> init_val = () => initializer.call(new TensorShape(shape), dtype: dtype); | ||
| 32 | 47 | ||
| 33 | 48 | var variable_dtype = dtype.as_base_dtype(); | |
| 34 | 49 | var v = tf.Variable(init_val); | |
@@ -44,21 +59,21 @@ public static RefVariable make_variable(string name, | |||
| 44 | 59 | public static string unique_layer_name(string name, Dictionary<(string, string), int> name_uid_map = null, | |
| 45 | 60 | string[] avoid_names = null, string @namespace = "", bool zero_based = false) | |
| 46 | 61 | { | |
| 47 | - if(name_uid_map == null) | ||
| 62 | + if (name_uid_map == null) | ||
| 48 | 63 | name_uid_map = get_default_graph_uid_map(); | |
| 49 | 64 | if (avoid_names == null) | |
| 50 | 65 | avoid_names = new string[0]; | |
| 51 | 66 | ||
| 52 | 67 | string proposed_name = null; | |
| 53 | - while(proposed_name == null || avoid_names.Contains(proposed_name)) | ||
| 68 | + while (proposed_name == null || avoid_names.Contains(proposed_name)) | ||
| 54 | 69 | { | |
| 55 | 70 | var name_key = (@namespace, name); | |
| 56 | 71 | if (!name_uid_map.ContainsKey(name_key)) | |
| 57 | 72 | name_uid_map[name_key] = 0; | |
| 58 | 73 | ||
| 59 | 74 | if (zero_based) | |
| 60 | 75 | { | |
| 61 | - int number = name_uid_map[name_key]; | ||
| 76 | + int number = name_uid_map[name_key]; | ||
| 62 | 77 | if (number > 0) | |
| 63 | 78 | proposed_name = $"{name}_{number}"; | |
| 64 | 79 | else | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,111 +14,111 @@ public class ExamplesTest | |||
| 14 | 14 | public void BasicOperations() | |
| 15 | 15 | { | |
| 16 | 16 | tf.Graph().as_default(); | |
| 17 | - new BasicOperations() { Enabled = true }.Train(); | ||
| 17 | + new BasicOperations() { Enabled = true }.Run(); | ||
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | 20 | [TestMethod] | |
| 21 | 21 | public void HelloWorld() | |
| 22 | 22 | { | |
| 23 | 23 | tf.Graph().as_default(); | |
| 24 | - new HelloWorld() { Enabled = true }.Train(); | ||
| 24 | + new HelloWorld() { Enabled = true }.Run(); | ||
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | 27 | [TestMethod] | |
| 28 | 28 | public void ImageRecognition() | |
| 29 | 29 | { | |
| 30 | 30 | tf.Graph().as_default(); | |
| 31 | - new HelloWorld() { Enabled = true }.Train(); | ||
| 31 | + new HelloWorld() { Enabled = true }.Run(); | ||
| 32 | 32 | } | |
| 33 | 33 | ||
| 34 | 34 | [Ignore] | |
| 35 | 35 | [TestMethod] | |
| 36 | 36 | public void InceptionArchGoogLeNet() | |
| 37 | 37 | { | |
| 38 | 38 | tf.Graph().as_default(); | |
| 39 | - new InceptionArchGoogLeNet() { Enabled = true }.Train(); | ||
| 39 | + new InceptionArchGoogLeNet() { Enabled = true }.Run(); | ||
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | 42 | [TestMethod] | |
| 43 | 43 | public void KMeansClustering() | |
| 44 | 44 | { | |
| 45 | 45 | tf.Graph().as_default(); | |
| 46 | - new KMeansClustering() { Enabled = true, IsImportingGraph = true, train_size = 500, validation_size = 100, test_size = 100, batch_size =100 }.Train(); | ||
| 46 | + new KMeansClustering() { Enabled = true, IsImportingGraph = true, train_size = 500, validation_size = 100, test_size = 100, batch_size =100 }.Run(); | ||
| 47 | 47 | } | |
| 48 | 48 | ||
| 49 | 49 | [TestMethod] | |
| 50 | 50 | public void LinearRegression() | |
| 51 | 51 | { | |
| 52 | 52 | tf.Graph().as_default(); | |
| 53 | - new LinearRegression() { Enabled = true }.Train(); | ||
| 53 | + new LinearRegression() { Enabled = true }.Run(); | ||
| 54 | 54 | } | |
| 55 | 55 | ||
| 56 | 56 | [TestMethod] | |
| 57 | 57 | public void LogisticRegression() | |
| 58 | 58 | { | |
| 59 | 59 | tf.Graph().as_default(); | |
| 60 | - new LogisticRegression() { Enabled = true, training_epochs=10, train_size = 500, validation_size = 100, test_size = 100 }.Train(); | ||
| 60 | + new LogisticRegression() { Enabled = true, training_epochs=10, train_size = 500, validation_size = 100, test_size = 100 }.Run(); | ||
| 61 | 61 | } | |
| 62 | 62 | ||
| 63 | 63 | [Ignore] | |
| 64 | 64 | [TestMethod] | |
| 65 | 65 | public void NaiveBayesClassifier() | |
| 66 | 66 | { | |
| 67 | 67 | tf.Graph().as_default(); | |
| 68 | - new NaiveBayesClassifier() { Enabled = false }.Train(); | ||
| 68 | + new NaiveBayesClassifier() { Enabled = false }.Run(); | ||
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | 71 | [Ignore] | |
| 72 | 72 | [TestMethod] | |
| 73 | 73 | public void NamedEntityRecognition() | |
| 74 | 74 | { | |
| 75 | 75 | tf.Graph().as_default(); | |
| 76 | - new NamedEntityRecognition() { Enabled = true }.Train(); | ||
| 76 | + new NamedEntityRecognition() { Enabled = true }.Run(); | ||
| 77 | 77 | } | |
| 78 | 78 | ||
| 79 | 79 | [TestMethod] | |
| 80 | 80 | public void NearestNeighbor() | |
| 81 | 81 | { | |
| 82 | 82 | tf.Graph().as_default(); | |
| 83 | - new NearestNeighbor() { Enabled = true, TrainSize = 500, ValidationSize = 100, TestSize = 100 }.Train(); | ||
| 83 | + new NearestNeighbor() { Enabled = true, TrainSize = 500, ValidationSize = 100, TestSize = 100 }.Run(); | ||
| 84 | 84 | } | |
| 85 | 85 | ||
| 86 | 86 | [Ignore] | |
| 87 | 87 | [TestMethod] | |
| 88 | 88 | public void TextClassificationTrain() | |
| 89 | 89 | { | |
| 90 | 90 | tf.Graph().as_default(); | |
| 91 | - new TextClassificationTrain() { Enabled = true, DataLimit=100 }.Train(); | ||
| 91 | + new TextClassificationTrain() { Enabled = true, DataLimit=100 }.Run(); | ||
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | 94 | [Ignore] | |
| 95 | 95 | [TestMethod] | |
| 96 | 96 | public void TextClassificationWithMovieReviews() | |
| 97 | 97 | { | |
| 98 | 98 | tf.Graph().as_default(); | |
| 99 | - new BinaryTextClassification() { Enabled = true }.Train(); | ||
| 99 | + new BinaryTextClassification() { Enabled = true }.Run(); | ||
| 100 | 100 | } | |
| 101 | 101 | ||
| 102 | 102 | [TestMethod] | |
| 103 | 103 | public void NeuralNetXor() | |
| 104 | 104 | { | |
| 105 | 105 | tf.Graph().as_default(); | |
| 106 | - Assert.IsTrue(new NeuralNetXor() { Enabled = true, IsImportingGraph = false }.Train()); | ||
| 106 | + Assert.IsTrue(new NeuralNetXor() { Enabled = true, IsImportingGraph = false }.Run()); | ||
| 107 | 107 | } | |
| 108 | 108 | ||
| 109 | 109 | [TestMethod] | |
| 110 | 110 | public void NeuralNetXor_ImportedGraph() | |
| 111 | 111 | { | |
| 112 | 112 | tf.Graph().as_default(); | |
| 113 | - Assert.IsTrue(new NeuralNetXor() { Enabled = true, IsImportingGraph = true }.Train()); | ||
| 113 | + Assert.IsTrue(new NeuralNetXor() { Enabled = true, IsImportingGraph = true }.Run()); | ||
| 114 | 114 | } | |
| 115 | 115 | ||
| 116 | 116 | ||
| 117 | 117 | [TestMethod] | |
| 118 | 118 | public void ObjectDetection() | |
| 119 | 119 | { | |
| 120 | 120 | tf.Graph().as_default(); | |
| 121 | - Assert.IsTrue(new ObjectDetection() { Enabled = true, IsImportingGraph = true }.Train()); | ||
| 121 | + Assert.IsTrue(new ObjectDetection() { Enabled = true, IsImportingGraph = true }.Run()); | ||
| 122 | 122 | } | |
| 123 | 123 | } | |
| 124 | 124 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments