Skip to content

Commit 4cd985a

Browse files
committed
fix _enter_scope_uncached exception when _scope is null.
1 parent bc4fbf1 commit 4cd985a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/TensorFlowNET.Core/Variables/variable_scope.py.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ private VariableScope _enter_scope_uncached()
122122

123123
if (!string.IsNullOrEmpty(_name) || _scope != null)
124124
{
125-
var name_scope = _scope.name.Split('/').Last();
125+
var name_scope = _scope == null ? _name : _scope.name.Split('/').Last();
126126
if (current_name_scope == null)
127127
current_name_scope = ops.name_scope(name_scope);
128128
current_name_scope.__enter__();
129-
var current_name_scope_name = current_name_scope;
129+
string current_name_scope_name = current_name_scope;
130130
_current_name_scope = current_name_scope;
131-
string old_name_scope = _scope.original_name_scope;
131+
string old_name_scope = _scope == null ? current_name_scope_name : _scope.original_name_scope;
132132

133133
if(_scope == null)
134134
pure_variable_scope = new PureVariableScope(_name, old_name_scope: old_name_scope);

0 commit comments

Comments
 (0)