From ce69b487dcd426940a759eecbfeb058b00011de0 Mon Sep 17 00:00:00 2001 From: Krishnan Date: Mon, 16 Jul 2018 17:38:50 +0530 Subject: [PATCH] Update random_variables.py --- edward/util/random_variables.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/edward/util/random_variables.py b/edward/util/random_variables.py index 3a581505a..a78fc4565 100644 --- a/edward/util/random_variables.py +++ b/edward/util/random_variables.py @@ -359,18 +359,24 @@ def copy(org_instance, dict_swap=None, scope="copied", # It is unique to every Operation type. op_def = deepcopy(op.op_def) + # If it has inputs, copy them. + inputs = [] + for x in op.inputs: + elem = copy(x, dict_swap, scope, True, copy_q, False) + if not isinstance(elem, tf.Operation): + elem = tf.convert_to_tensor(elem) + + inputs.append(elem) + new_op = tf.Operation(node_def, graph, - [], # inputs; will add them afterwards + inputs, output_types, [], # control inputs; will add them afterwards [], # input types; will add them afterwards original_op, op_def) - # advertise op early to break recursions - graph._add_op(new_op) - # If it has control inputs, copy them. control_inputs = [] for x in op.control_inputs: @@ -382,14 +388,6 @@ def copy(org_instance, dict_swap=None, scope="copied", new_op._add_control_inputs(control_inputs) - # If it has inputs, copy them. - for x in op.inputs: - elem = copy(x, dict_swap, scope, True, copy_q, False) - if not isinstance(elem, tf.Operation): - elem = tf.convert_to_tensor(elem) - - new_op._add_input(elem) - # Copy the control flow context. control_flow_context = _copy_context(op._get_control_flow_context(), {}, dict_swap, scope, copy_q)