errors in merging two layers output

1,504 views
Skip to first unread message

tct...@gmail.com

unread,
Jan 21, 2017, 12:37:40 PM1/21/17
to Keras-users
Hi, dear all, I have problem about merging two layers output, the code is listed as below:


input1 = Input(batch_shape=(shape[0],shape[1],I1_dim))
input2 = Input(batch_shape=(shape[0],shape[1],shape[2]-I1_dim))
test1 = LSTM(32)(input1)
test2 = LSTM(100)(input2)
encoded = Merge([input1,test2],mode='concat')

How can I fix this problem?

Thank you very much!

Christos Baziotis

unread,
Jan 21, 2017, 12:43:06 PM1/21/17
to Keras-users, tct...@gmail.com
input1 = Input(batch_shape=(shape[0],shape[1],I1_dim))
input2
= Input(batch_shape=(shape[0],shape[1],shape[2]-I1_dim))
test1
= LSTM(32)(input1)
test2
= LSTM(100)(input2)

encoded
= Merge([test1,test2],mode='concat') # put test1 not input1


tct...@gmail.com

unread,
Jan 21, 2017, 12:49:35 PM1/21/17
to Keras-users
Thank you, even I change it, it still does not work.

Matias Valdenegro

unread,
Jan 21, 2017, 12:55:39 PM1/21/17
to keras...@googlegroups.com

Hi,

 

Fix what problem? You have not told us what the actual problem is.

tct...@gmail.com

unread,
Jan 21, 2017, 1:10:15 PM1/21/17
to Keras-users
Sorry for missing. I am not with my computer now, but I remember it says the tensor variables does not have some method. The inputs that will be merged are tensor variables type.

tct...@gmail.com

unread,
Jan 21, 2017, 3:24:16 PM1/21/17
to Keras-users, tct...@gmail.com
When I change it like this:
input1 = Input(batch_shape=(shape[0],shape[1],I1_dim))
input2 = Input(batch_shape=(shape[0],shape[1],shape[2]-I1_dim))
test1 = LSTM(32)(input1)
test2 = LSTM(100)(input2)
encoded = Merge([test1,test2],mode='concat')

It has the error:
  File "/home/fxt120230/Application/pycharm-community-2016.2.3/helpers/pydev/pydevd.py", line 1580, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/fxt120230/Application/pycharm-community-2016.2.3/helpers/pydev/pydevd.py", line 964, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/fxt120230/Study/MSP/Research/WhisperRecognition/ETECode/isete_lib.py", line 111, in <module>
    AttentionSeq2Seq(output_dim=output_dim,hidden_dim=hidden_dim,I1_dim=I1_dim,output_length=output_length, batch_input_shape=(samples,input_length, input_dim))
  File "/home/fxt120230/Study/MSP/Research/WhisperRecognition/ETECode/isete_lib.py", line 79, in AttentionSeq2Seq
    encoded = Merge([test1,test2],mode='concat')
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.0-py2.7.egg/keras/engine/topology.py", line 1293, in __init__
    node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.0-py2.7.egg/keras/engine/topology.py", line 1317, in _arguments_validation
    layer_output_shape = layer.get_output_shape_at(node_indices[i])
AttributeError: 'TensorVariable' object has no attribute 'get_output_shape_at'
Exception TypeError: TypeError("'NoneType' object is not callable",) in <bound method __AptDpkgPackageInfo.__del__ of <apport.packaging_impl.__AptDpkgPackageInfo instance at 0x7f75ea81b4d0>> ignored

tct...@gmail.com

unread,
Jan 21, 2017, 3:24:38 PM1/21/17
to Keras-users
The error is:
  File "/home/fxt120230/Application/pycharm-community-2016.2.3/helpers/pydev/pydevd.py", line 1580, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/fxt120230/Application/pycharm-community-2016.2.3/helpers/pydev/pydevd.py", line 964, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/fxt120230/Study/MSP/Research/WhisperRecognition/ETECode/isete_lib.py", line 111, in <module>
    AttentionSeq2Seq(output_dim=output_dim,hidden_dim=hidden_dim,I1_dim=I1_dim,output_length=output_length, batch_input_shape=(samples,input_length, input_dim))
  File "/home/fxt120230/Study/MSP/Research/WhisperRecognition/ETECode/isete_lib.py", line 79, in AttentionSeq2Seq
    encoded = Merge([test1,test2],mode='concat')
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.0-py2.7.egg/keras/engine/topology.py", line 1293, in __init__
    node_indices, tensor_indices)
  File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.0-py2.7.egg/keras/engine/topology.py", line 1317, in _arguments_validation
    layer_output_shape = layer.get_output_shape_at(node_indices[i])
AttributeError: 'TensorVariable' object has no attribute 'get_output_shape_at'
Exception TypeError: TypeError("'NoneType' object is not callable",) in <bound method __AptDpkgPackageInfo.__del__ of <apport.packaging_impl.__AptDpkgPackageInfo instance at 0x7f75ea81b4d0>> ignored

Thank you.

Matias Valdenegro

unread,
Jan 21, 2017, 3:41:40 PM1/21/17
to keras...@googlegroups.com

For the functional API you have to use merge (from keras.layers), not Merge. Note the case sensitivity.

tct...@gmail.com

unread,
Jan 21, 2017, 4:08:03 PM1/21/17
to Keras-users
Thank you, I got your reply. It works now.


On Saturday, January 21, 2017 at 11:55:39 AM UTC-6, Matias Valdenegro wrote:
Reply all
Reply to author
Forward
0 new messages