| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a22e92d commit ebfb327
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -203,49 +203,21 @@ public static IEnumerable<T> reversed<T>(IList<T> values) | |||
| 203 | 203 | yield return values[i]; | |
| 204 | 204 | } | |
| 205 | 205 | ||
| 206 | - [DebuggerStepThrough] | ||
| 207 | - public static void tf_with(ITensorFlowObject py, Action<ITensorFlowObject> action) | ||
| 208 | - { | ||
| 209 | - try | ||
| 210 | - { | ||
| 211 | - py.__enter__(); | ||
| 212 | - action(py); | ||
| 213 | - } | ||
| 214 | - finally | ||
| 215 | - { | ||
| 216 | - py.__exit__(); | ||
| 217 | - py.Dispose(); | ||
| 218 | - } | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | 206 | [DebuggerStepThrough] | |
| 222 | 207 | public static void tf_with<T>(T py, Action<T> action) where T : ITensorFlowObject | |
| 223 | 208 | { | |
| 224 | - try | ||
| 225 | - { | ||
| 226 | - py.__enter__(); | ||
| 227 | - action(py); | ||
| 228 | - } | ||
| 229 | - finally | ||
| 230 | - { | ||
| 231 | - py.__exit__(); | ||
| 232 | - py.Dispose(); | ||
| 233 | - } | ||
| 209 | + py.__enter__(); | ||
| 210 | + action(py); | ||
| 211 | + py.__exit__(); | ||
| 234 | 212 | } | |
| 235 | 213 | ||
| 236 | 214 | [DebuggerStepThrough] | |
| 237 | 215 | public static TOut tf_with<TIn, TOut>(TIn py, Func<TIn, TOut> action) where TIn : ITensorFlowObject | |
| 238 | 216 | { | |
| 239 | - try | ||
| 240 | - { | ||
| 241 | - py.__enter__(); | ||
| 242 | - return action(py); | ||
| 243 | - } | ||
| 244 | - finally | ||
| 245 | - { | ||
| 246 | - py.__exit__(); | ||
| 247 | - py.Dispose(); | ||
| 248 | - } | ||
| 217 | + py.__enter__(); | ||
| 218 | + var result = action(py); | ||
| 219 | + py.__exit__(); | ||
| 220 | + return result; | ||
| 249 | 221 | } | |
| 250 | 222 | ||
| 251 | 223 | public static float time() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,21 +60,22 @@ public static (Tensor, Tensor) get_seed_tensor(int? op_seed = null) | |||
| 60 | 60 | var (seed, seed2) = get_seed(op_seed); | |
| 61 | 61 | Tensor _seed, _seed2; | |
| 62 | 62 | if (seed is null) | |
| 63 | - _seed = constant_op.constant(0, dtype: TF_DataType.TF_INT64, name: "seed"); | ||
| 63 | + _seed = constant_op.constant(0L, name: "seed"); | ||
| 64 | 64 | else | |
| 65 | - _seed = constant_op.constant(seed.Value, dtype: TF_DataType.TF_INT64, name: "seed"); | ||
| 65 | + _seed = constant_op.constant((long)seed.Value, name: "seed"); | ||
| 66 | 66 | ||
| 67 | 67 | if (seed2 is null) | |
| 68 | - _seed2 = constant_op.constant(0, dtype: TF_DataType.TF_INT64, name: "seed2"); | ||
| 68 | + _seed2 = constant_op.constant(0L, name: "seed2"); | ||
| 69 | 69 | else | |
| 70 | 70 | { | |
| 71 | 71 | _seed2 = tf_with(ops.name_scope("seed2"), scope => | |
| 72 | 72 | { | |
| 73 | - _seed2 = constant_op.constant(seed2.Value, dtype: TF_DataType.TF_INT64); | ||
| 73 | + _seed2 = constant_op.constant((long)seed2.Value); | ||
| 74 | 74 | return array_ops.where_v2( | |
| 75 | 75 | math_ops.logical_and( | |
| 76 | - math_ops.equal(_seed, 0l), math_ops.equal(_seed2, 0l)), | ||
| 77 | - constant_op.constant(2^31 - 1, dtype: dtypes.int64), | ||
| 76 | + math_ops.equal(_seed, 0L), | ||
| 77 | + math_ops.equal(_seed2, 0L)), | ||
| 78 | + constant_op.constant(2^31L - 1), | ||
| 78 | 79 | _seed2, | |
| 79 | 80 | name: scope); | |
| 80 | 81 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,7 @@ limitations under the License. | |||
| 21 | 21 | ||
| 22 | 22 | namespace Tensorflow | |
| 23 | 23 | { | |
| 24 | - public class Session : BaseSession, ITensorFlowObject | ||
| 24 | + public class Session : BaseSession | ||
| 25 | 25 | { | |
| 26 | 26 | public Session(string target = "", Graph g = null) : base(target, g, null) | |
| 27 | 27 | { } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | <PropertyGroup> | |
| 4 | 4 | <TargetFramework>netstandard2.0</TargetFramework> | |
| 5 | - <AssemblyName>TensorFlow.NET</AssemblyName> | ||
| 5 | + <AssemblyName>Tensorflow.Binding</AssemblyName> | ||
| 6 | 6 | <RootNamespace>Tensorflow</RootNamespace> | |
| 7 | 7 | <TargetTensorFlow>2.2.0</TargetTensorFlow> | |
| 8 | 8 | <Version>0.70.0</Version> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -99,15 +99,16 @@ public void __enter__() | |||
| 99 | 99 | [DebuggerStepThrough] | |
| 100 | 100 | public void Dispose() | |
| 101 | 101 | { | |
| 102 | - if (tf.Context.executing_eagerly()) | ||
| 103 | - tf.Context.ScopeName = old_scope_name; | ||
| 104 | - else | ||
| 105 | - get_default_graph()._name_stack = old_scope_name; | ||
| 102 | + | ||
| 106 | 103 | } | |
| 107 | 104 | ||
| 108 | 105 | [DebuggerStepThrough] | |
| 109 | 106 | public void __exit__() | |
| 110 | 107 | { | |
| 108 | + if (tf.Context.executing_eagerly()) | ||
| 109 | + tf.Context.ScopeName = old_scope_name; | ||
| 110 | + else | ||
| 111 | + get_default_graph()._name_stack = old_scope_name; | ||
| 111 | 112 | } | |
| 112 | 113 | ||
| 113 | 114 | [DebuggerNonUserCode] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,18 +33,20 @@ public Tensors Apply(Tensors inputs, Tensor state = null, bool training = false) | |||
| 33 | 33 | else | |
| 34 | 34 | nameScope = _name_scope(); | |
| 35 | 35 | ||
| 36 | - tf_with(ops.name_scope(nameScope), scope => | ||
| 37 | - { | ||
| 38 | - if (!built) | ||
| 39 | - MaybeBuild(inputs); | ||
| 36 | + var scope = ops.name_scope(nameScope); | ||
| 37 | + scope.__enter__(); | ||
| 38 | + | ||
| 39 | + if (!built) | ||
| 40 | + MaybeBuild(inputs); | ||
| 41 | + | ||
| 42 | + outputs = Call(inputs, state: state, training: training); | ||
| 40 | 43 | ||
| 41 | - outputs = Call(inputs, state: state, training: training); | ||
| 44 | + // memory leak | ||
| 45 | + // _set_connectivity_metadata_(inputs, outputs); | ||
| 46 | + _handle_activity_regularization(inputs, outputs); | ||
| 47 | + _set_mask_metadata(inputs, outputs, null); | ||
| 42 | 48 | ||
| 43 | - // memory leak | ||
| 44 | - // _set_connectivity_metadata_(inputs, outputs); | ||
| 45 | - _handle_activity_regularization(inputs, outputs); | ||
| 46 | - _set_mask_metadata(inputs, outputs, null); | ||
| 47 | - }); | ||
| 49 | + scope.__exit__(); | ||
| 48 | 50 | ||
| 49 | 51 | return outputs; | |
| 50 | 52 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,26 +26,27 @@ Tensors FunctionalConstructionCall(Tensors inputs) | |||
| 26 | 26 | var graph = keras.backend.get_graph(); | |
| 27 | 27 | graph.as_default(); | |
| 28 | 28 | ||
| 29 | - tf_with(ops.name_scope(_name_scope()), scope => | ||
| 30 | - { | ||
| 31 | - MaybeBuild(inputs); | ||
| 32 | - | ||
| 33 | - // Wrapping `call` function in autograph to allow for dynamic control | ||
| 34 | - // flow and control dependencies in call. We are limiting this to | ||
| 35 | - // subclassed layers as autograph is strictly needed only for | ||
| 36 | - // subclassed layers and models. | ||
| 37 | - // tf_convert will respect the value of autograph setting in the | ||
| 38 | - // enclosing tf.function, if any. | ||
| 39 | - if (!dynamic) | ||
| 40 | - throw new NotImplementedException(""); | ||
| 41 | - | ||
| 42 | - outputs = Call(inputs); | ||
| 29 | + var scope = ops.name_scope(_name_scope()); | ||
| 30 | + scope.__enter__(); | ||
| 31 | + | ||
| 32 | + MaybeBuild(inputs); | ||
| 33 | + | ||
| 34 | + // Wrapping `call` function in autograph to allow for dynamic control | ||
| 35 | + // flow and control dependencies in call. We are limiting this to | ||
| 36 | + // subclassed layers as autograph is strictly needed only for | ||
| 37 | + // subclassed layers and models. | ||
| 38 | + // tf_convert will respect the value of autograph setting in the | ||
| 39 | + // enclosing tf.function, if any. | ||
| 40 | + if (!dynamic) | ||
| 41 | + throw new NotImplementedException(""); | ||
| 42 | + | ||
| 43 | + outputs = Call(inputs); | ||
| 43 | 44 | ||
| 44 | - _set_connectivity_metadata_(inputs, outputs); | ||
| 45 | - _handle_activity_regularization(inputs, outputs); | ||
| 46 | - _set_mask_metadata(inputs, outputs, null); | ||
| 47 | - }); | ||
| 45 | + _set_connectivity_metadata_(inputs, outputs); | ||
| 46 | + _handle_activity_regularization(inputs, outputs); | ||
| 47 | + _set_mask_metadata(inputs, outputs, null); | ||
| 48 | 48 | ||
| 49 | + scope.__exit__(); | ||
| 49 | 50 | graph.Exit(); | |
| 50 | 51 | ||
| 51 | 52 | return outputs; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,7 +60,7 @@ Keras is an API designed for human beings, not machines. Keras follows best prac | |||
| 60 | 60 | </PropertyGroup> | |
| 61 | 61 | ||
| 62 | 62 | <ItemGroup> | |
| 63 | - <PackageReference Include="HDF5-CSharp" Version="1.12.4" /> | ||
| 63 | + <PackageReference Include="HDF5-CSharp" Version="1.12.5" /> | ||
| 64 | 64 | <PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.144" /> | |
| 65 | 65 | <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |
| 66 | 66 | <PackageReference Include="SharpZipLib" Version="1.3.3" /> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments