diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs index d525dc66..1bfa81f2 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs @@ -73,9 +73,9 @@ namespace Tensorflow.Operations // Use the real value if it comes from outer context. This is needed in // particular for nested conds. if (_external_values.ContainsKey(val.name)) - result = _external_values[val.name]; - else - result = val; + result = _external_values[val.name]; + + result = result == null ? val : result; } else { @@ -89,6 +89,11 @@ namespace Tensorflow.Operations _external_values[result.name] = result; } + // for debug purpose + if(ops.get_default_graph()._nodes_by_name.Count > 60) + { + } + with(ops.control_dependencies(null), ctrl => { var (r0, r1) = control_flow_ops._SwitchRefOrTensor(result, _pred); diff --git a/src/TensorFlowNET.Core/Operations/Operation.cs b/src/TensorFlowNET.Core/Operations/Operation.cs index deab05f1..9f4280d9 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.cs @@ -279,11 +279,13 @@ namespace Tensorflow /// the Tensor to be used as the input at the given index. public void _update_input(int index, Tensor tensor) { + _assert_same_graph(tensor); + var input = _tf_input(index); - var output = tensor._as_tf_output(); - _assert_same_graph( tensor); - // Reset cached inputs. - _inputs=new InputList(new Tensor[]{ tensor }); // is this right? original code: self._inputs_val=None + var output = tensor._as_tf_output(); + + // Reset cached inputs. + _inputs = null;// new InputList(new Tensor[] { tensor }); // is this right? original code: self._inputs_val=None // TODO: implement below code dependencies //c_api.UpdateEdge(_graph._c_graph, output, input); }