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

AssertionError: Shape of params are incompatible #42

Closed
jbuehler1337 opened this issue May 8, 2020 · 7 comments
Closed

AssertionError: Shape of params are incompatible #42

jbuehler1337 opened this issue May 8, 2020 · 7 comments

Comments

@jbuehler1337
Copy link

Hi again,

I am a bit confused about this error, happening in the 4_text_denoising notebook. I just did every step from before but something does not fit with the dimensions. Can you explain why this is happening?

AssertionErrorTraceback (most recent call last)
<ipython-input-31-2a0e848a57c4> in <module>
      1 model_path = 'models/denoiser2.params'
      2 if (os.path.isfile(model_path)):
----> 3     net.load_parameters(model_path, ctx=ctx)
      4     print("Loaded parameters")
      5     best_test_loss = evaluate(net, val_data_ft)

/usr/local/lib/python3.6/dist-packages/mxnet/gluon/block.py in load_parameters(self, filename, ctx, allow_missing, ignore_extra, cast_dtype, dtype_source)
    553                         name, filename, _brief_print_list(self._params.keys())))
    554             if name in params:
--> 555                 params[name]._load_init(loaded[name], ctx, cast_dtype=cast_dtype, dtype_source=dtype_source)
    556 
    557     def load_params(self, filename, ctx=None, allow_missing=False,

/usr/local/lib/python3.6/dist-packages/mxnet/gluon/parameter.py in _load_init(self, data, ctx, cast_dtype, dtype_source)
    280                     "Failed loading Parameter '%s' from saved params: " \
    281                     "shape incompatible expected %s vs saved %s"%(
--> 282                         self.name, str(self.shape), str(data.shape))
    283             self.shape = tuple(i if i != unknown_dim_size else j
    284                                for i, j in zip(self.shape, data.shape))

AssertionError: Failed loading Parameter 'transformer_enc_const' from saved params: shape incompatible expected (150, 512) vs saved (150, 256)
@jonomon
Copy link
Contributor

jonomon commented May 8, 2020

Are you using the IAM images?

@jbuehler1337
Copy link
Author

Yes I am using the IAM data from the official page and your code just like you described it in the read me. I did not change the data set. Just lowered the number of workers or the batch size (32 to 16) to prevent my GPU memory to be overloaded...
How can I solve this? Can I see the dimensions somehow? Do you need any further information?

@jonomon
Copy link
Contributor

jonomon commented May 8, 2020

Were you able to run through 0_handwriting_ocr.ipynb without any issues?

@jbuehler1337
Copy link
Author

Yes I run through 0_handwriting_ocr.ipynb , 1_a_paragraph_segmentation_msers.ipynb , 1_b_paragraph_segmentation_dcnn.ipynb, 2_line_word_segmentation.ipynb , 3_handwriting_recognition.ipynb notebooks without an error.

@jbuehler1337
Copy link
Author

Hey, are there any news? Can I support you with additional information?

@jonomon
Copy link
Contributor

jonomon commented May 13, 2020

There was a typo in the code.

Please change

num_heads = 16
embed_size = 512
num_layers = 2

epochs = 5
key = 'language_denoising'
best_test_loss = 10e20

learning_rate = 0.00004
send_every_n = 50

to

num_heads = 16
embed_size = 256
num_layers = 2

epochs = 5
key = 'language_denoising'
best_test_loss = 10e20

learning_rate = 0.00004
send_every_n = 50

@jbuehler1337
Copy link
Author

Thank you @jonomon so much, it is working fine now.

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

2 participants