AttributeError: cannot assign module before Module.__init__() call
I am getting the following error. AttributeError: cannot assign module before Module.__init__() call I have a class as follows. <SCODE>                                                   args.nlayers, args.dropout)
<ECODE> So, when I run the following line: question_classifier = QuestionClassifier(corpus.dictionary, embeddings_index, corpus.max_sent_length, args) What I am doing wrong here?
wasiahmad
The first thing you should always do when you create a module is call its super constructor… So, your class should look like this: <SCODE>class QuestionClassifier(nn.Module):

    def __init__(self, dictionary, embeddings_index, max_seq_length, args):
        """"Constructor of the class"""
        super(QuestionClassifier, self).__init__()

        self.embedding = EmbeddingLayer(len(dictionary), args.emsize, args.dropout)
        self.encoder = EncoderRNN(args.emsize, args.nhid, args.model, args.bidirection, args.nlayers, args.dropout)
        
        self.drop = nn.Dropout(args.dropout)<ECODE>
miguelvr
AbdulsalamBande