bug fixed: for loss and accuracy calculation in train.py #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Torch version:
![part_1](https://private-user-images.githubusercontent.com/19332990/317586028-f606a11c-7d43-4054-8032-f12fe1ea12dd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MDM0NTIsIm5iZiI6MTcyNTQwMzE1MiwicGF0aCI6Ii8xOTMzMjk5MC8zMTc1ODYwMjgtZjYwNmExMWMtN2Q0My00MDU0LTgwMzItZjEyZmUxZWExMmRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDIyMzkxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU2NzcwZmFhMGU5OTJlZjJmMjhmMDZiMGJjN2YyZmNmNjE3ZWVlODBiNzExZGMzMzM2MjNiNTg2YzM2NzkxNGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.s7J60Ib6OdcjsnWokihhQoHbpluRRuXKoq3oiJ3QT3k)
1.12.0+cu102
Google Colab CPU runtime.
First error:
so,
![part_2](https://private-user-images.githubusercontent.com/19332990/317586515-47c235bf-3d48-4223-9201-5954bd62d8ba.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MDM0NTIsIm5iZiI6MTcyNTQwMzE1MiwicGF0aCI6Ii8xOTMzMjk5MC8zMTc1ODY1MTUtNDdjMjM1YmYtM2Q0OC00MjIzLTkyMDEtNTk1NGJkNjJkOGJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDIyMzkxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEwZWFiNDAxNGQ1NWVhNmI3OGI1ZTBiMTBlNmQ2YzFjMWRhZGRiYWVlMzQwZDk1NmIyMmM5ZDc5NzI3NjY0ZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8lfIhOKhvvfS13yyu9qxBGnAfEOLnbfnPlKDmCR8yhU)
torch._C._nn.cross_entropy_loss
function accepts a tensor.solve: pass the tensor while calculating loss.
Then, another error occurred:
![part_3](https://private-user-images.githubusercontent.com/19332990/317586554-01ff4a0f-f76e-433c-b0f8-a2b17f498f87.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50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LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDIyMzkxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBlZjFmNjUxYWUwODAxMjNjYmZhZTFlMDZiNjc1YmNmNWFjM2I0YTIwZTJiOTg5MDA0YjdhOGMwYWJiNWMyYzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.YbUkupmLgeznBoIA7ytZBJMGAhZPgEloQz-Ms9Ywp7Q)
loss
variable must befloat
type as it handles float type dataThen, another error occurred:
![part_6](https://private-user-images.githubusercontent.com/19332990/317586712-d4f8eb85-6795-424a-8cc4-8db507d1362a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MDM0NTIsIm5iZiI6MTcyNTQwMzE1MiwicGF0aCI6Ii8xOTMzMjk5MC8zMTc1ODY3MTItZDRmOGViODUtNjc5NS00MjRhLThjYzQtOGRiNTA3ZDEzNjJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDIyMzkxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJjMzg5YWFmYWRlZGE0NjBlNjIxYWRmYjVkY2FkNTI0MmFmZGUzM2I2YmY0MTcxM2YyYmU3MmU2NWYwMzM3NjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.12tNHXlDR4h8kBeXm58gWDZ8KahN8RuGhaXrAtiIrL0)
So, again, pass the tensor while calculating accuracy:
![part7](https://private-user-images.githubusercontent.com/19332990/317587269-07e6687f-fd3b-418d-902d-df5d54521e49.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MDM0NTIsIm5iZiI6MTcyNTQwMzE1MiwicGF0aCI6Ii8xOTMzMjk5MC8zMTc1ODcyNjktMDdlNjY4N2YtZmQzYi00MThkLTkwMmQtZGY1ZDU0NTIxZTQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDIyMzkxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyMWQ3OWQ4NzllNjdiOTFkODZkYmZlMDIyMGI0NTBiMDkwNDY3NWNlMmUwNGQ3ZGY4NjgzMjI1Y2NmNDdkZjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1RqxEe1LOKhTzz4GonScZRgjnoXJmKkKXBDpxrTknHg)
Finally, it's running successfully:
![part_8](https://private-user-images.githubusercontent.com/19332990/317587304-d74fdf14-cce4-4ed5-8acd-60acfd29f584.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MDM0NTIsIm5iZiI6MTcyNTQwMzE1MiwicGF0aCI6Ii8xOTMzMjk5MC8zMTc1ODczMDQtZDc0ZmRmMTQtY2NlNC00ZWQ1LThhY2QtNjBhY2ZkMjlmNTg0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAzVDIyMzkxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVlM2YwZmRjNzEzMTQ1ODQ1ZTJkNmFmOGY3OTQ5ZDNmMWNmYmMyNWY1NDY4MjRmMjM4N2RmMmNjMTNmZjJjY2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Yefgu9waOT7Q2wl6960_NJATq9tO2angPRhTClkVl14)