diff --git a/src/TensorFlowNET.Core/Framework/meta_graph.py.cs b/src/TensorFlowNET.Core/Framework/meta_graph.py.cs index 24be2cd6c..c7af70512 100644 --- a/src/TensorFlowNET.Core/Framework/meta_graph.py.cs +++ b/src/TensorFlowNET.Core/Framework/meta_graph.py.cs @@ -136,11 +136,14 @@ public static (MetaGraphDef, Dictionary) export_scoped_meta var graph = ops.get_default_graph(); var var_list = new Dictionary(); - var variables = graph.get_collection(ops.GraphKeys.GLOBAL_VARIABLES); + var variables = graph.get_collection(ops.GraphKeys.GLOBAL_VARIABLES) as List; - foreach(var v in variables as List) + if (variables != null) { - var_list[v.name] = v; + foreach (var v in variables) + { + var_list[v.name] = v; + } } var scoped_meta_graph_def = create_meta_graph_def(