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

Error when batch size is not a factor of the number of samples in transformers_multiclass_classification.ipynb #6

Open
rachel-sorek opened this issue Jul 14, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@rachel-sorek
Copy link

re: transformers_multiclass_classification.ipynb

Thank you for this helpful tutorial!

It seems to work well when the batch size (either for training or validation) is a factor of the number of examples, but otherwise I get the following error message:
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

For example:
with batch_size =4,
3172 samples works, but 3171 or 3173 return an error.

@abhimishra91 abhimishra91 self-assigned this Aug 12, 2020
@abhimishra91 abhimishra91 added the question Further information is requested label Aug 12, 2020
@abhimishra91
Copy link
Owner

@rachel-sorek , thank you for raising the request.

I did not run into this issue myself, but then again i did not tweak the dataset size or the batch size much. I will run the notebook with these changes at my end and let you know the results.

@GalMoore
Copy link

GalMoore commented Sep 4, 2020

I faced the same issue. Would be good to have some checking mechanism to round down to the closest multiple that doesn't crash with a warning message explaining that part of the data has been discarded.

@maheshmechengg
Copy link

re: transformers_multiclass_classification.ipynb

Thank you for this helpful tutorial!

It seems to work well when the batch size (either for training or validation) is a factor of the number of examples, but otherwise I get the following error message: IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

For example: with batch_size =4, 3172 samples works, but 3171 or 3173 return an error.

You may find this link helpful, when if input_ids & attention_mask are of different size then we get this error.
https://stackoverflow.com/questions/65851195/runtimeerror-stack-expects-each-tensor-to-be-equal-size

I got same error after i updated pad_to_max_length=True, in Trigne class to padding=True.

When i switched to original worked fine again.

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

No branches or pull requests

4 participants