transformers-tutorials
transformers-tutorials copied to clipboard
Error when batch size is not a factor of the number of samples in transformers_multiclass_classification.ipynb
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.
@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.
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.
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.