ValueError: Duplicate node name in graph: 'lambda_1/zeros/packed'
C:\Users\pc\AppData\Local\Programs\Python\Python37\python.exe C:/Users/pc/AppData/Local/Temp/helloworld.py/attention.py
Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\ops\array_ops.py", line 2355, in zeros
tensor_shape.TensorShape(shape))
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 776, in __init__
self._dims = [as_dimension(d) for d in dims_iter]
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 776, in
self._dims = [as_dimension(d) for d in dims_iter]
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 718, in as_dimension
return Dimension(value)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 193, in __init__
self._value = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Tensor'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 1610, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Duplicate node name in graph: 'lambda_1/zeros/packed'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/pc/AppData/Local/Temp/helloworld.py/attention.py", line 254, in
model = get_model(Tx, Ty, layer1_size, layer2_size, human_vocab_size, machine_vocab_size)
File "C:/Users/pc/AppData/Local/Temp/helloworld.py/attention.py", line 243, in get_model
a2 = attention_layer(a1, layer2_size, Ty)
File "C:/Users/pc/AppData/Local/Temp/helloworld.py/attention.py", line 200, in attention_layer
h = Lambda(lambda X: K.zeros(shape=(K.shape(X)[0], n_h)))(X)
File "C:\Users\pc\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 75, in symbolic_fn_wrapper
return func(*args, **kwargs)
File "C:\Users\pc\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\engine\base_layer.py", line 506, in __call__
output_shape = self.compute_output_shape(input_shape)
File "C:\Users\pc\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\layers\core.py", line 677, in compute_output_shape
x = self.call(x)
File "C:\Users\pc\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\layers\core.py", line 716, in call
return self.function(inputs, **arguments)
File "C:/Users/pc/AppData/Local/Temp/helloworld.py/attention.py", line 200, in
h = Lambda(lambda X: K.zeros(shape=(K.shape(X)[0], n_h)))(X)
File "C:\Users\pc\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 963, in zeros
v = tf.zeros(shape=shape, dtype=dtype, name=name)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\ops\array_ops.py", line 2358, in zeros
shape = ops.convert_to_tensor(shape, dtype=dtypes.int32)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 1184, in convert_to_tensor
return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 1242, in convert_to_tensor_v2
as_ref=False)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 1296, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\ops\array_ops.py", line 1278, in _autopacking_conversion_function
return _autopacking_helper(v, dtype, name or "packed")
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\ops\array_ops.py", line 1214, in _autopacking_helper
return gen_array_ops.pack(elems_as_tensors, name=scope)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\ops\gen_array_ops.py", line 6303, in pack
"Pack", values=values, axis=axis, name=name)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\op_def_library.py", line 793, in _apply_op_helper
op_def=op_def)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\func_graph.py", line 548, in create_op
compute_device)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 3429, in _create_op_internal
op_def=op_def)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 1773, in __init__
control_input_ops)
File "C:\Users\pc\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\framework\ops.py", line 1613, in _create_c_op
raise ValueError(str(e))
ValueError: Duplicate node name in graph: 'lambda_1/zeros/packed'
Process finished with exit code 1
参考
https://www.e-learn.cn/topic/1561943