| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7bc249f commit ded16ea
29 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,7 +63,7 @@ public Tensor conv2d(Tensor inputs, | |||
| 63 | 63 | trainable: trainable, | |
| 64 | 64 | name: name); | |
| 65 | 65 | ||
| 66 | - return layer.apply(inputs); | ||
| 66 | + return layer.apply(inputs).Item1; | ||
| 67 | 67 | } | |
| 68 | 68 | ||
| 69 | 69 | /// <summary> | |
@@ -117,7 +117,7 @@ public Tensor batch_normalization(Tensor inputs, | |||
| 117 | 117 | trainable: trainable, | |
| 118 | 118 | name: name); | |
| 119 | 119 | ||
| 120 | - return layer.apply(inputs, training: training); | ||
| 120 | + return layer.apply(inputs, training: training).Item1; | ||
| 121 | 121 | } | |
| 122 | 122 | ||
| 123 | 123 | /// <summary> | |
@@ -143,7 +143,7 @@ public Tensor max_pooling2d(Tensor inputs, | |||
| 143 | 143 | data_format: data_format, | |
| 144 | 144 | name: name); | |
| 145 | 145 | ||
| 146 | - return layer.apply(inputs); | ||
| 146 | + return layer.apply(inputs).Item1; | ||
| 147 | 147 | } | |
| 148 | 148 | ||
| 149 | 149 | /// <summary> | |
@@ -179,7 +179,7 @@ public Tensor dense(Tensor inputs, | |||
| 179 | 179 | kernel_initializer: kernel_initializer, | |
| 180 | 180 | trainable: trainable); | |
| 181 | 181 | ||
| 182 | - return layer.apply(inputs); | ||
| 182 | + return layer.apply(inputs).Item1; | ||
| 183 | 183 | } | |
| 184 | 184 | ||
| 185 | 185 | /// <summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,7 +76,7 @@ public Tensor dropout(Tensor x, Tensor keep_prob = null, Tensor noise_shape = nu | |||
| 76 | 76 | /// <param name="swap_memory"></param> | |
| 77 | 77 | /// <param name="time_major"></param> | |
| 78 | 78 | /// <returns>A pair (outputs, state)</returns> | |
| 79 | - public (Tensor, Tensor) dynamic_rnn(RNNCell cell, Tensor inputs, | ||
| 79 | + public (Tensor, Tensor) dynamic_rnn(RnnCell cell, Tensor inputs, | ||
| 80 | 80 | Tensor sequence_length = null, TF_DataType dtype = TF_DataType.DtInvalid, | |
| 81 | 81 | int? parallel_iterations = null, bool swap_memory = false, bool time_major = false) | |
| 82 | 82 | => rnn.dynamic_rnn(cell, inputs, sequence_length: sequence_length, dtype: dtype, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ limitations under the License. | |||
| 18 | 18 | using System.Diagnostics.CodeAnalysis; | |
| 19 | 19 | using System.Linq; | |
| 20 | 20 | using Tensorflow.Operations; | |
| 21 | + using static Tensorflow.Binding; | ||
| 21 | 22 | ||
| 22 | 23 | namespace Tensorflow | |
| 23 | 24 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -262,15 +262,11 @@ public Operation create_op(string op_type, Tensor[] inputs, TF_DataType[] dtypes | |||
| 262 | 262 | ||
| 263 | 263 | if (string.IsNullOrEmpty(name)) | |
| 264 | 264 | name = op_type; | |
| 265 | + | ||
| 265 | 266 | // If a names ends with a '/' it is a "name scope" and we use it as-is, | |
| 266 | 267 | // after removing the trailing '/'. | |
| 267 | 268 | name = name.EndsWith("/") ? ops.name_from_scope_name(name) : unique_name(name); | |
| 268 | 269 | var node_def = ops._NodeDef(op_type, name, device: "", attrs: attrs); | |
| 269 | - | ||
| 270 | - if (name.Contains("define_loss/bigger_box_loss/mul_13")) | ||
| 271 | - { | ||
| 272 | - | ||
| 273 | - } | ||
| 274 | 270 | ||
| 275 | 271 | var input_ops = inputs.Select(x => x.op).ToArray(); | |
| 276 | 272 | var control_inputs = _control_dependencies_for_inputs(input_ops); | |
@@ -377,7 +373,11 @@ public string name_scope(string name) | |||
| 377 | 373 | /// <returns>A string to be passed to `create_op()` that will be used | |
| 378 | 374 | /// to name the operation being created.</returns> | |
| 379 | 375 | public string unique_name(string name, bool mark_as_used = true) | |
| 380 | - { | ||
| 376 | + { | ||
| 377 | + if (name.EndsWith("basic_r_n_n_cell")) | ||
| 378 | + { | ||
| 379 | + | ||
| 380 | + } | ||
| 381 | 381 | if (!String.IsNullOrEmpty(_name_stack)) | |
| 382 | 382 | name = _name_stack + "/" + name; | |
| 383 | 383 | // For the sake of checking for names in use, we treat names as case | |
@@ -405,7 +405,7 @@ public string unique_name(string name, bool mark_as_used = true) | |||
| 405 | 405 | ||
| 406 | 406 | // Return the new name with the original capitalization of the given name. | |
| 407 | 407 | name = $"{name}_{i-1}"; | |
| 408 | - } | ||
| 408 | + } | ||
| 409 | 409 | return name; | |
| 410 | 410 | } | |
| 411 | 411 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ limitations under the License. | |||
| 16 | 16 | ||
| 17 | 17 | using System.Collections.Generic; | |
| 18 | 18 | using Tensorflow.Operations; | |
| 19 | + using static Tensorflow.Binding; | ||
| 19 | 20 | ||
| 20 | 21 | namespace Tensorflow | |
| 21 | 22 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | 5 | namespace Tensorflow | |
| 6 | 6 | { | |
| 7 | - public interface IPackable | ||
| 7 | + public interface IPackable<T> | ||
| 8 | 8 | { | |
| 9 | - void Pack(object[] sequences); | ||
| 9 | + T Pack(object[] sequences); | ||
| 10 | 10 | } | |
| 11 | 11 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,14 +139,14 @@ protected override void build(TensorShape input_shape) | |||
| 139 | 139 | built = true; | |
| 140 | 140 | } | |
| 141 | 141 | ||
| 142 | - protected override Tensor call(Tensor inputs, Tensor training = null) | ||
| 142 | + protected override (Tensor, Tensor) call(Tensor inputs, Tensor training = null) | ||
| 143 | 143 | { | |
| 144 | 144 | Tensor outputs = null; | |
| 145 | 145 | ||
| 146 | 146 | if (fused) | |
| 147 | 147 | { | |
| 148 | 148 | outputs = _fused_batch_norm(inputs, training: training); | |
| 149 | - return outputs; | ||
| 149 | + return (outputs, outputs); | ||
| 150 | 150 | } | |
| 151 | 151 | ||
| 152 | 152 | throw new NotImplementedException("BatchNormalization call"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,7 +108,7 @@ protected override void build(TensorShape input_shape) | |||
| 108 | 108 | built = true; | |
| 109 | 109 | } | |
| 110 | 110 | ||
| 111 | - protected override Tensor call(Tensor inputs, Tensor training = null) | ||
| 111 | + protected override (Tensor, Tensor) call(Tensor inputs, Tensor training = null) | ||
| 112 | 112 | { | |
| 113 | 113 | var outputs = _convolution_op.__call__(inputs, kernel); | |
| 114 | 114 | if (use_bias) | |
@@ -124,9 +124,9 @@ protected override Tensor call(Tensor inputs, Tensor training = null) | |||
| 124 | 124 | } | |
| 125 | 125 | ||
| 126 | 126 | if (activation != null) | |
| 127 | - return activation.Activate(outputs); | ||
| 127 | + outputs = activation.Activate(outputs); | ||
| 128 | 128 | ||
| 129 | - return outputs; | ||
| 129 | + return (outputs, outputs); | ||
| 130 | 130 | } | |
| 131 | 131 | } | |
| 132 | 132 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,7 +72,7 @@ protected override void build(TensorShape input_shape) | |||
| 72 | 72 | built = true; | |
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | - protected override Tensor call(Tensor inputs, Tensor training = null) | ||
| 75 | + protected override (Tensor, Tensor) call(Tensor inputs, Tensor training = null) | ||
| 76 | 76 | { | |
| 77 | 77 | Tensor outputs = null; | |
| 78 | 78 | var rank = inputs.rank; | |
@@ -88,9 +88,9 @@ protected override Tensor call(Tensor inputs, Tensor training = null) | |||
| 88 | 88 | if (use_bias) | |
| 89 | 89 | outputs = tf.nn.bias_add(outputs, bias); | |
| 90 | 90 | if (activation != null) | |
| 91 | - return activation.Activate(outputs); | ||
| 91 | + outputs = activation.Activate(outputs); | ||
| 92 | 92 | ||
| 93 | - return outputs; | ||
| 93 | + return (outputs, outputs); | ||
| 94 | 94 | } | |
| 95 | 95 | } | |
| 96 | 96 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,14 +50,14 @@ protected override void build(TensorShape input_shape) | |||
| 50 | 50 | built = true; | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | - protected override Tensor call(Tensor inputs, Tensor training = null) | ||
| 53 | + protected override (Tensor, Tensor) call(Tensor inputs, Tensor training = null) | ||
| 54 | 54 | { | |
| 55 | 55 | var dtype = inputs.dtype; | |
| 56 | 56 | if (dtype != tf.int32 && dtype != tf.int64) | |
| 57 | 57 | inputs = math_ops.cast(inputs, tf.int32); | |
| 58 | 58 | ||
| 59 | 59 | var @out = embedding_ops.embedding_lookup(embeddings, inputs); | |
| 60 | - return @out; | ||
| 60 | + return (@out, @out); | ||
| 61 | 61 | } | |
| 62 | 62 | } | |
| 63 | 63 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments