title: AttributeError: cannot assign module before Module.__init__() call
body: <p>I am getting the following error.</p>
  
  <pre><code>Traceback (most recent call last):
    File "main.py", line 63, in &lt;module&gt;
      question_classifier = QuestionClassifier(corpus.dictionary, embeddings_index, corpus.max_sent_length, args)
    File "/net/if5/wua4nw/wasi/academic/research_with_prof_chang/projects/question_answering/duplicate_question_detection/source/question_classifier.py", line 26, in __init__
      self.embedding = EmbeddingLayer(len(dictionary), args.emsize, args.dropout)
    File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/torch/nn/modules/module.py", line 255, in __setattr__
      "cannot assign module before Module.__init__() call")
  AttributeError: cannot assign module before Module.__init__() call
  </code></pre>
  
  <p>I have a class as follows.</p>
  
  <pre><code>class QuestionClassifier(nn.Module):
  
       def __init__(self, dictionary, embeddings_index, max_seq_length, args):
           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)
  </code></pre>
  
  <p>So, when I run the following line:</p>
  
  <pre><code>question_classifier = QuestionClassifier(corpus.dictionary, embeddings_index, corpus.max_sent_length, args)
  </code></pre>
  
  <p>I get the above mentioned error. Here, <code>EmbeddingLayer</code> and <code>EncoderRNN</code> is a class written by me which inherits <code>nn.module</code> like the <code>QuestionClassifier</code> class.</p>
  
  <p>What I am doing wrong here?</p>