Skip to content

Commit 10c2aee

Browse files
authored
Merge pull request SciSharp#219 from henon/master
meta_graph.py.cs: fixed nullref exception
2 parents dd91139 + 26e78cd commit 10c2aee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/TensorFlowNET.Core/Framework/meta_graph.py.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,14 @@ public static (MetaGraphDef, Dictionary<string, RefVariable>) export_scoped_meta
136136
var graph = ops.get_default_graph();
137137

138138
var var_list = new Dictionary<string, RefVariable>();
139-
var variables = graph.get_collection(ops.GraphKeys.GLOBAL_VARIABLES);
139+
var variables = graph.get_collection(ops.GraphKeys.GLOBAL_VARIABLES) as List<RefVariable>;
140140

141-
foreach(var v in variables as List<RefVariable>)
141+
if (variables != null)
142142
{
143-
var_list[v.name] = v;
143+
foreach (var v in variables)
144+
{
145+
var_list[v.name] = v;
146+
}
144147
}
145148

146149
var scoped_meta_graph_def = create_meta_graph_def(

0 commit comments

Comments
 (0)