From 4359d35850701282308ef0c6f404db29b11dd495 Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Sun, 22 Nov 2020 13:15:10 -0600 Subject: [PATCH] fix scope name for init_scope(). --- src/TensorFlowNET.Core/Binding.Util.cs | 5 +---- src/TensorFlowNET.Core/Variables/ResourceVariable.cs | 2 +- src/TensorFlowNET.Core/ops.cs | 1 + src/TensorFlowNET.Core/ops.name_scope.cs | 6 +++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/TensorFlowNET.Core/Binding.Util.cs b/src/TensorFlowNET.Core/Binding.Util.cs index 0411227f..4043ad49 100644 --- a/src/TensorFlowNET.Core/Binding.Util.cs +++ b/src/TensorFlowNET.Core/Binding.Util.cs @@ -166,7 +166,6 @@ namespace Tensorflow } [DebuggerStepThrough] - [DebuggerNonUserCode()] // with "Just My Code" enabled this lets the debugger break at the origin of the exception public static void tf_with(ITensorFlowObject py, Action action) { try @@ -181,8 +180,7 @@ namespace Tensorflow } } - [DebuggerStepThrough] - [DebuggerNonUserCode()] // with "Just My Code" enabled this lets the debugger break at the origin of the exception + // [DebuggerStepThrough] public static void tf_with(T py, Action action) where T : ITensorFlowObject { try @@ -198,7 +196,6 @@ namespace Tensorflow } [DebuggerStepThrough] - [DebuggerNonUserCode()] // with "Just My Code" enabled this lets the debugger break at the origin of the exception public static TOut tf_with(TIn py, Func action) where TIn : ITensorFlowObject { try diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.cs index 2cff02c2..30ae1a43 100644 --- a/src/TensorFlowNET.Core/Variables/ResourceVariable.cs +++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.cs @@ -87,9 +87,9 @@ namespace Tensorflow if (trainable && !collections.Contains(tf.GraphKeys.TRAINABLE_VARIABLES)) collections.Add(tf.GraphKeys.TRAINABLE_VARIABLES); - _in_graph_mode = !tf.Context.executing_eagerly(); tf_with(ops.init_scope(), init_scope => { + _in_graph_mode = !tf.Context.executing_eagerly(); var values = init_from_fn ? new object[0] : new object[] { initial_value }; tf_with(ops.name_scope(name, "Variable", values, skip_on_eager: false), scope => { diff --git a/src/TensorFlowNET.Core/ops.cs b/src/TensorFlowNET.Core/ops.cs index 0744c068..67926caf 100644 --- a/src/TensorFlowNET.Core/ops.cs +++ b/src/TensorFlowNET.Core/ops.cs @@ -296,6 +296,7 @@ namespace Tensorflow // outer_device_stack = None }); + tf.Context.ScopeName = scope; return ops.name_scope(scope); } diff --git a/src/TensorFlowNET.Core/ops.name_scope.cs b/src/TensorFlowNET.Core/ops.name_scope.cs index 984efaec..a81de8e3 100644 --- a/src/TensorFlowNET.Core/ops.name_scope.cs +++ b/src/TensorFlowNET.Core/ops.name_scope.cs @@ -48,7 +48,7 @@ namespace Tensorflow _skip_on_eager = skip_on_eager; } - // [DebuggerStepThrough] + [DebuggerStepThrough] public void __enter__() { if (tf.Context.executing_eagerly()) @@ -96,7 +96,7 @@ namespace Tensorflow return (scope_name, old_name); } - [DebuggerHidden] + [DebuggerStepThrough] public void Dispose() { if (tf.Context.executing_eagerly()) @@ -105,7 +105,7 @@ namespace Tensorflow get_default_graph()._name_stack = old_scope_name; } - [DebuggerNonUserCode] + [DebuggerStepThrough] public void __exit__() { }