fastai / course-v3

The 3rd edition of course.fast.ai
https://course.fast.ai/
Apache License 2.0
4.91k stars 3.57k forks source link

Fix for the error, IndexError: index 3 is out of bounds for dimension 0 with size 3, in 05_anneal.ipynb #525

Closed rraminen closed 4 years ago

rraminen commented 4 years ago

IndexError: index 3 is out of bounds for dimension 0 with size 3

torch.linspace() behaviour differs in different PyTorch versions. For example, for T = torch.linspace(0.01, 1, 100), value of T[99] is 0.99XXXXXX in version 1.4.0 value of T[99] is 1 in torch versions > 1.4.0

Hence modified the function def _inner() by adding 'if idx == 2: idx = 1' to work as expected.

review-notebook-app[bot] commented 4 years ago

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

SpellOnYou commented 4 years ago

Hi, @rraminen I have run the same error, and found this PR. Maybe you did, I wanted to find out why this error occur. And I tested as you suggested, resulting in no difference between two versions. you can check what I did here

you can message me, and my fastai forum username is spellonyou, would be pleased to getting an answer & making studymate 🙌

rraminen commented 4 years ago

Hi @SpellOnYou ,

Try using .item() to see the actual values in each of the variables in two different versions. For example p[99].item(). Let me know if you don't see different values. Thanks, Ramya

cerenaaa commented 3 years ago

IndexError: index 3 is out of bounds for dimension 0 with size 3

torch.linspace() behaviour differs in different PyTorch versions. For example, for T = torch.linspace(0.01, 1, 100), value of T[99] is 0.99XXXXXX in version 1.4.0 value of T[99] is 1 in torch versions > 1.4.0

Hence modified the function def _inner() by adding 'if idx == 2: idx = 1' to work as expected.

For lay people who don't know what to do with this error in a Jupyter Notebook, can you tell me what I should do, step by step, to prevent this error?

Thank you!