title: AttributeError: 'numpy.ndarray' object has no attribute 'A'
body: <p>I am trying to perform tfidf on a matrix. I would like to use gensim, but <code>models.TfidfModel()</code> only works on a corpus and therefore returns a list of lists of varying lengths (I want a matrix).</p>
  
  <p>The options are to somehow fill in the missing values of the list of lists, or just convert the corpus to a matrix </p>
  
  <pre><code>numpy_matrix = gensim.matutils.corpus2dense(corpus, num_terms=number_of_corpus_features)
  </code></pre>
  
  <p>Choosing the latter, I then try to convert this count matrix to a tf-idf weighted matrix:</p>
  
  <pre><code>def TFIDF(m):
      #import numpy
      WordsPerDoc = numpy.sum(m, axis=0)
      DocsPerWord = numpy.sum(numpy.asarray(m &gt; 0, 'i'), axis=1)
      rows, cols = m.shape
      for i in range(rows):
          for j in range(cols):
              amatrix[i,j] = (amatrix[i,j] / WordsPerDoc[j]) * log(float(cols) /     DocsPerWord[i])
  </code></pre>
  
  <p>But, I get the error <code>AttributeError: 'numpy.ndarray' object has no attribute 'A'</code></p>
  
  <p>I copied the function above from another script. It was:</p>
  
  <pre><code>def TFIDF(self):
      WordsPerDoc = sum(self.A, axis=0)        
      DocsPerWord = sum(asarray(self.A &gt; 0, 'i'), axis=1)
      rows, cols = self.A.shape
      for i in range(rows):
         for j in range(cols):
            self.A[i,j] = (self.A[i,j] / WordsPerDoc[j]) * log(float(cols) / DocsPerWord[i])
  </code></pre>
  
  <p>Which I believe is where it's getting the <code>A</code> from. However, I re-imported the function. </p>
  
  <p>Why is this happening?</p>