From 8cb647082cd4a75b60f3ee9ca565bba7494b6fa3 Mon Sep 17 00:00:00 2001 From: Eli Belash Date: Fri, 30 Aug 2019 19:39:26 +0300 Subject: [PATCH] Graph.Operation: Throw ValueError exception when `Current graph is not default graph.` --- src/TensorFlowNET.Core/Graphs/Graph.Operation.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs b/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs index 0e28dd9a..3cda8074 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs @@ -54,19 +54,21 @@ namespace Tensorflow var handle = return_oper_handle.node + tf_op_size * i; return_opers[i] = new Operation(*(IntPtr*)handle); } - } - + } + return return_opers; } public Operation OperationByName(string operName) { var handle = c_api.TF_GraphOperationByName(_handle, operName); - if(graph_key != tf.get_default_graph().graph_key) - { - Console.WriteLine($"Current graph is not default graph."); - // throw new ValueError($"Current graph is not default graph."); + var defaultKey = tf.get_default_graph().graph_key; + if (graph_key != defaultKey) + { + //Console.WriteLine($"Current graph is not default graph."); + throw new ValueError($"Current graph is not default graph. Default Graph Key: {defaultKey}, Current Graph Key: {graph_key}"); } + return new Operation(handle, g: this); }