title: ValueError: cannot reshape array of size 3800 into shape (1,200)
body: <p>I am trying to apply word embedding on tweets. I was trying to create a vector for each tweet by taking the average of the vectors of the words present in the tweet as follow:</p>
  
  <pre><code>def word_vector(tokens, size):
      vec = np.zeros(size).reshape((1, size))
      count = 0.
      for word in tokens:
          try:
              vec += model_w2v[word].reshape((1, size))
              count += 1.
          except KeyError: # handling the case where the token is not in vocabulary
  
              continue
      if count != 0:
          vec /= count
      return vec
  </code></pre>
  
  <p>Next, when I try to Prepare word2vec feature set as follow:</p>
  
  <pre><code>wordvec_arrays = np.zeros((len(tokenized_tweet), 200))
  #the length of the vector is 200
  
  for i in range(len(tokenized_tweet)):
      wordvec_arrays[i,:] = word_vector(tokenized_tweet[i], 200)
  
  wordvec_df = pd.DataFrame(wordvec_arrays)
  wordvec_df.shape
  </code></pre>
  
  <p>I get the following error inside the loop:</p>
  
  <blockquote>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-32-72aee891e885&gt; in &lt;module&gt;
        4 # wordvec_arrays.reshape(1,200)
        5 for i in range(len(tokenized_tweet)):
  ----&gt; 6     wordvec_arrays[i,:] = word_vector(tokenized_tweet[i], 200)
        7 
        8 wordvec_df = pd.DataFrame(wordvec_arrays)
  
  &lt;ipython-input-31-9e6501810162&gt; in word_vector(tokens, size)
        4     for word in tokens:
        5         try:
  ----&gt; 6             vec += model_w2v.wv.__getitem__(word).reshape((1, size))
        7             count += 1.
        8         except KeyError: # handling the case where the token is not in vocabulary
  
  ValueError: cannot reshape array of size 3800 into shape (1,200)
  </code></pre>
  </blockquote>
  
  <p>I checked all the available posts in stackOverflow but non of them really helped me.</p>
  
  <p>I tried reshaping the array and it still give me the same error. </p>
  
  <p>My model is:</p>
  
  <pre><code>tokenized_tweet = df['tweet'].apply(lambda x: x.split()) # tokenizing
  
  model_w2v = gensim.models.Word2Vec(
              tokenized_tweet,
              size=200, # desired no. of features/independent variables 
              window=5, # context window size
              min_count=2,
              sg = 1, # 1 for skip-gram model
              hs = 0,
              negative = 10, # for negative sampling
              workers= 2, # no.of cores
              seed = 34)
  
  model_w2v.train(tokenized_tweet, total_examples= len(df['tweet']), epochs=20)
  </code></pre>
  
  <p>any suggestions please? </p>