Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Apply map function when peeking in tensorflow #129

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

edknv
Copy link
Contributor

@edknv edknv commented Apr 6, 2023

.peek() is supposed to produce the same output as next() without advancing the iterator:

def __next__(self):
"""Get the next batch from the dataloader"""
converted_batch = self.convert_batch(super().__next__())
for map_fn in self._map_fns:
converted_batch = map_fn(*converted_batch)
return converted_batch

but the .map() functionality in peek() got dropped after the recent dataloader changes, while __next__ still applies the map function properly. This PR applies the same logic currently in __next__ to peek(). Models currently makes use of this combination: map() and peek().

@edknv edknv force-pushed the map_when_peek branch 3 times, most recently from 9719942 to c797261 Compare April 6, 2023 05:18
@edknv edknv self-assigned this Apr 6, 2023
@edknv edknv added the bug Something isn't working label Apr 6, 2023
@edknv edknv added this to the Merlin 23.04 milestone Apr 6, 2023
@edknv edknv marked this pull request as ready for review April 6, 2023 05:34
@@ -88,7 +88,11 @@ def __next__(self):
def peek(self):
"""Grab the next batch from the dataloader
without removing it from the queue"""
return self.convert_batch(self._peek_next_batch())
converted_batch = self.convert_batch(self._peek_next_batch())
for map_fn in self._map_fns:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the same applies to the peek method of the torch dataloader too. Would it work to move these methods (__next__/peek) to the base class like we had before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either in this PR or a new one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good point. I'll follow up with a new PR.

@edknv edknv merged commit e8dd3df into NVIDIA-Merlin:main Apr 6, 2023
@edknv edknv deleted the map_when_peek branch April 6, 2023 16:38
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants