I’m a new starter of pytorch. When I get my RNN model trained,I meet some problems about how to implements minibatch
my training data is a python list like
input:[‘word1’,‘word2’,‘word3’,‘word4’]
target: [‘tg1’,‘tg2’,‘tg3’,‘tg4’]
And I learn from web that I need to implements mydataset class and use DataLoader, but problems are as following:
class MyDataset(data.Dataset):
def __init__(self, words, labels):
self.words = words
self.labels = labels
def __getitem__(self, index):
input, target = self.words[index], self.labels[index]
return input, target
def __len__(self):
return len(self.words)
- Should the words and labels for dataset be type Variable?
- How to code the training part, if I want to have minibatch?
thanks for your answer