-
Notifications
You must be signed in to change notification settings - Fork 816
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
Added batch iteration into input and target variables (#285) #288
Conversation
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.
LGTM, just add a few brief comments when you manage and I'm merging this
torchtext/data/batch.py
Outdated
@@ -58,6 +62,20 @@ def __str__(self): | |||
def __len__(self): | |||
return self.batch_size | |||
|
|||
def _get_vars(self, target): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torchtext/data/batch.py
Outdated
def _get_vars(self, target): | ||
fields = self.target_fields if target else self.input_fields | ||
vars = tuple(getattr(self, f) for f in fields) | ||
if len(vars) == 0: |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Hi, thanks for the review! I changed the code to reflect my intent more clearly, I think this should resolve the above problems, but if anything can be improved please tell me :) |
Awesome, thanks, everything seems good now! |
Hey everyone, I ran into the same issue as @raheelqader in issue 422, with the "is_target" attribute being referenced for a "RawField" instance. I'd like to suggest we add an "is_target" attribute to "RawField" and set it to False by default. I'd like to contribute, but this is my first time. Should I just go ahead and do a PR once I've made the fix? Thanks! Looking forward to contributing. |
Hey, sure, feel free to submit a PR! |
Now, the batch can be iterated into input and target variables like
where
x1
tox3
are inputs to a downstream model andy
is the label data for this batch.