-
Notifications
You must be signed in to change notification settings - Fork 323
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
fix last batch index error reinforce #389
Conversation
Codecov Report
@@ Coverage Diff @@
## master #389 +/- ##
==========================================
+ Coverage 81.11% 81.18% +0.06%
==========================================
Files 100 100
Lines 5693 5714 +21
==========================================
+ Hits 4618 4639 +21
Misses 1075 1075
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@sid-sundrani Thank you for reporting and investigating the bug! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sid-sundrani LGTM! Thank you for your contribution and swift action :]
may we add also a test for this issue you have described? |
@Borda Hmm okay. Considering this issue, we'd want a test to check if there is an error when current batch size isn't equal to given batch size when calculating the loss? If we set If we set those parameters then would running something like this in TestReinforce work?
|
@sid-sundrani mind send a PR with adding test so we can talk about it there... |
What does this PR do?
This PR replaces getting batch size from self when calculating loss with using the length of the tensor, fixing an IndexError in Reinforce
The error was an IndexError (size mismatch) occurring on the last batch of the epoch because tensor size wasn't equal to
self.batch_size
. The number of samples in the dataset may not be divisible byself.batch_size
, because trajectory collection here is done based on the number of episodes rather than the number of samples. Rather than fixing the error usingdrop_last=True
in dataloader, this approach uses all trajectory dataFixes #381
Before submitting
Did you have fun?
Make sure you had fun coding 🙃