Add
super(QuestionClassifier, self).__init__()
after def __init__(self, dictionary, embeddings_index, max_seq_length, args): line
Pytorch keeps track of your custom class submodules like Embedding, nn.RNN using an ordered dictionary in addition to other things. And this dictionary is first initialized in nn.Module.  If you inherit nn.Module as you did in in the first line class QuestionClassifier(nn.Module): , you still need to call the __init__() method of  the nn.Module to initialize the ordered dictionary which will hold your submodules like nn.RNN. Use the super keyword to call the __init__() of the parent class.