XifengGuo / CapsNet-Keras

A Keras implementation of CapsNet in NIPS2017 paper "Dynamic Routing Between Capsules". Now test error = 0.34%.
MIT License
2.47k stars 651 forks source link

ValueError: Can not do batch dot #94

Closed shassa21 closed 4 years ago

shassa21 commented 5 years ago

I am getting the following error when trying to run the model (without editing anything):

ValueError: Can not do batch_dot on inputs with shapes (None, 10, 10, 1152, 16) and (None, 10, None, 1152, 16) with axes=[2, 3]. x.shape[2] != y.shape[3] (10 != 1152).

error

sai-krishna-msk commented 5 years ago

did you find/figure out the problem?

alexandrusoloms commented 5 years ago

Sorry if this is not the case, but to me it looks like a shape problem... have you tried np.reshape()?

sai-krishna-msk commented 5 years ago

Thanks for responding, I'll try

diazandr3s commented 5 years ago

Hi,

I've got the same error the first time I executed it. I solve it by changing the Keras and Python version. Initially I had the last version of both Keras (2.3.0) and Python (3.6.9). Now I'm using Keras 2.1.2 and Python 3.6.1. These are the requirements for a working virtual env:

absl-py==0.8.0 astor==0.8.0 certifi==2019.6.16 cycler==0.10.0 gast==0.3.2 google-pasta==0.1.7 grpcio==1.23.0 h5py==2.10.0 Keras==2.1.2 Keras-Applications==1.0.8 Keras-Preprocessing==1.1.0 kiwisolver==1.1.0 Markdown==3.1.1 matplotlib==3.1.1 numpy==1.17.2 pandas==0.25.1 Pillow==6.1.0 protobuf==3.9.1 pyparsing==2.4.2 python-dateutil==2.8.0 pytz==2019.2 PyYAML==5.1.2 scipy==1.3.1 six==1.12.0 tensorboard==1.14.0 tensorflow-estimator==1.14.0 tensorflow-gpu==1.14.0 termcolor==1.1.0 Theano==1.0.4 Werkzeug==0.15.6 wrapt==1.11.2

sai-krishna-msk commented 5 years ago

Thanks @diazandr3s :)

ghost commented 5 years ago

i want to know why version can lead this problom

noideanopaper commented 5 years ago

@diazandr3s Thanks, this is useful for me.

data-hound commented 4 years ago

I tried printing out the values, and errors, tracing all the shapes

Shape of Primary Caps:  (None, 1152, 8)
inputs expanded shape:  (None, 1, 1152, 8)
inputs_tiled shape: (None, 10, 1152, 8)
weights_shape:  (10, 1152, 16, 8)

ValueError: Cannot do batch_dot on inputs with shapes (None, 10, 10, 1152, 16) and (None, 10, 1152, 1152, 16) with axes=[2, 3]. x.shape[2] != y.shape[3] (10 != 1152).

Seems the shapes are changing at some point after the call