Forked from kabirahuja2431/iterable_dataloader_v0.py
Created
February 23, 2020 03:22
-
-
Save mrm8488/3430af1120ef07b5207402fb4cae5d56 to your computer and use it in GitHub Desktop.
This file contains 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
#Creating the iterable dataset object | |
dataset = CustomIterableDataset('path_to/somefile') | |
#Creating the dataloader | |
dataloader = DataLoader(dataset, batch_size = 64) | |
for data in dataloader: | |
#Data is a list containing 64 (=batch_size) consecutive lines of the file | |
print(len(data)) #[64,] | |
#We still need to separate the text and labels from each other and preprocess the text | |
X, y = [] | |
for i in range(len(data)): | |
text, label = data[i].split(',') | |
text = preprocess(text) #Defined somewhere outside | |
X.append(text) | |
y.append(label) | |
### Do something with X and y | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment