Created
January 27, 2020 13:27
-
-
Save aravindpai/f8c7d5dfcf50e98dd12c0f6f8aaf4e9b 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
#check whether cuda is available | |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | |
#set batch size | |
BATCH_SIZE = 64 | |
#Load an iterator | |
train_iterator, valid_iterator = data.BucketIterator.splits( | |
(train_data, valid_data), | |
batch_size = BATCH_SIZE, | |
sort_key = lambda x: len(x.text), | |
sort_within_batch=True, | |
device = device) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment