DeepCCA
DeepCCA copied to clipboard
Problem with merging models and building them
Hi: I took the code from GitHub and ran it in an Anaconda environment that has Keras 2.4.2 installed and ran into the following error:
runfile('M:/mypython/DeepCCA-master/DeepCCA.py', wdir='M:/mypython/DeepCCA-master') Reloaded modules: utils, linear_cca loading data ... loading data ... Traceback (most recent call last):
File "
File "C:\anaconda3\envs\keras\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile execfile(filename, namespace)
I tried to change the line containing "Merge" to "from keras.layers import Dense, merge" and the line to calling it to "merge" - that created the error:
File "M:\mypython\DeepCCA-master\models.py", line 19, in create_model model.add(merge([view1_model, view2_model], mode='concat'))
TypeError: 'module' object is not callable
Then I added "Concatenate" to the input and changed the line to "model.add(Concatenate([view1_model, view2_model]))". Now the data was loading OK but it failed when running "model.summary()" with:
File "C:\anaconda3\envs\keras\lib\site-packages\keras\engine\network.py", line 1252, in summary 'This model has not yet been built. '
ValueError: This model has not yet been built. Build the model first by calling build() or calling fit() with some data. Or specify input_shape or batch_input_shape in the first layer for automatic build.
Now I am at a loss how to proceed - I havn't used Keras until now. Thanks
File "C:\anaconda3\envs\keras\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile exec(compile(f.read(), filename, 'exec'), namespace)
File "M:/mypython/DeepCCA-master/DeepCCA.py", line 153, in
File "M:\mypython\DeepCCA-master\models.py", line 19, in create_model model.add(Merge([view1_model, view2_model], mode='concat'))
NameError: name 'Merge' is not defined
Try concatenate instead of Concatenate, merge or Merge. It worked for me.
Hi cbrelc, I got the same problem! I am testing the same code that you are testing. I got the same error:
NameError: name 'Merge' is not defined
,
though I have changed "Merge" to "concatenate".
model.add(concatenate([view1_model, view2_model]))
Not sure what happened...
#10 I hope this will help.
model.add(concatenate([view1_model, view2_model])) Got a syntax error SyntaxError: invalid syntax
I'm facing the same issue, I've tried some fixes with concatenate, merge etc, but none of them worked.. Please help
I also have a problem with concatenate:
File "C:\Users\hamid\PycharmProjects\pythonProject\venv\lib\site-packages\keras\layers\merging\concatenate.py", line 95, in build if len(input_shape) < 1 or not isinstance(input_shape[0], tuple): TypeError: object of type 'NoneType' has no len()