Last active
February 23, 2020 03:20
-
-
Save kabirahuja2431/d0c61b007f833f443537c3501afc5e41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from torch.utils.data import IterableDataset | |
class CustomIterableDataset(IterableDataset): | |
def __init__(self, filename): | |
#Store the filename in object's memory | |
self.filename = filename | |
#And that's it, we no longer need to store the contents in the memory | |
def __iter__(self): | |
#Create an iterator | |
file_itr = open(self.filename) | |
return file_itr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment