From 26e78cd14c200d9bd0c4640a2931e61723bb5003 Mon Sep 17 00:00:00 2001 From: Meinrad Recheis Date: Wed, 10 Apr 2019 14:45:59 +0200 Subject: [PATCH] meta_graph.py.cs: fixed nullref exception --- src/TensorFlowNET.Core/Framework/meta_graph.py.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(