Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router Code not running #8

Open
abhincho opened this issue Nov 1, 2019 · 2 comments
Open

Router Code not running #8

abhincho opened this issue Nov 1, 2019 · 2 comments

Comments

@abhincho
Copy link

abhincho commented Nov 1, 2019

Hi,
When I try to run the code routers_regularization.py I get the following error:
244 ######build the model#########
245 encoder = MLP()
--> 246 m1, m1_r = MultiHeadsAttModel(l=neighbors)
247 m2, m2_r = MultiHeadsAttModel(l=neighbors)
248 q_net = Q_Net(action_dim = action_space)

4 frames
in MultiHeadsAttModel(l, d, dv, dout, nv)
214 att = Lambda(lambda x: K.batch_dot(x[0],x[1] ,axes=[3,3]) / np.sqrt(dv))([q,k])# l, nv, nv
215 att_ = Lambda(lambda x: K.softmax(x))(att)
--> 216 out = Lambda(lambda x: K.batch_dot(x[0], x[1],axes=[3,2]))([att, v])
217 out = Lambda(lambda x: K.permute_dimensions(x, (0,2,1,3)))(out)
218

/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py in call(self, inputs, **kwargs)
449 # Actually call the layer,
450 # collecting output(s), mask(s), and shape(s).
--> 451 output = self.call(inputs, **kwargs)
452 output_mask = self.compute_mask(inputs, previous_mask)
453

/usr/local/lib/python3.6/dist-packages/keras/layers/core.py in call(self, inputs, mask)
714 else:
715 self._input_dtypes = K.dtype(inputs)
--> 716 return self.function(inputs, **arguments)
717
718 def compute_mask(self, inputs, mask=None):

in (x)
214 att = Lambda(lambda x: K.batch_dot(x[0],x[1] ,axes=[3,3]) / np.sqrt(dv))([q,k])# l, nv, nv
215 att_ = Lambda(lambda x: K.softmax(x))(att)
--> 216 out = Lambda(lambda x: K.batch_dot(x[0], x[1],axes=[3,2]))([att, v])
217 out = Lambda(lambda x: K.permute_dimensions(x, (0,2,1,3)))(out)
218

/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in batch_dot(x, y, axes)
1259 str(x_shape) + ' and ' + str(y_shape) +
1260 ' with axes=' + str(axes) + '. x.shape[%d] != '
-> 1261 'y.shape[%d] (%d != %d).' % (axes[0], axes[1], d1, d2))
1262
1263 # backup ndims. Need them later.

ValueError: Can not do batch_dot on inputs with shapes (None, 8, 4, 8, 4) and (None, 8, 4, 16) with axes=[3, 2]. x.shape[3] != y.shape[2] (8 != 4).
Kindly tell me what is causing the error so that I can fix it.

@laker-sprus
Copy link

try this: pip install keras==2.0.8

@yangyang-666
Copy link

我也是遇到这个问题。我是按照requirements.txt.中要求下载的TensorFlow==2.1.0 和Keras==2.3.1,用Spyder运行的时候,就出现这个错误。请问怎么解决呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants