title: ValueError: setting an array element with a sequence in Python
body: <p>First off, here's my code: </p>
  
  <pre><code>"""Softmax."""
  
  scores = [3.0, 1.0, 0.2]
  
  import numpy as np
  
  def softmax(x):
      """Compute softmax values for each sets of scores in x."""
      num = np.exp(x)
      score_len = len(x)
      y = np.array([0]*score_len)
      sum_n = np.sum(num)
      #print sum_n
      for index in range(1,score_len):
          y[index] = (num[index])/sum_n
      return y
  
  print(softmax(scores))
  </code></pre>
  
  <p>The error comes up at the line: </p>
  
  <p><code>y[index] = (num[index])/sum_n</code></p>
  
  <p>I run the code with: </p>
  
  <pre><code># Plot softmax curves
  import matplotlib.pyplot as plt
  x = np.arange(-2.0, 6.0, 0.1)
  scores = np.vstack([x, np.ones_like(x), 0.2 * np.ones_like(x)])
  
  plt.plot(x, softmax(scores).T, linewidth=2)
  plt.show()
  </code></pre>
  
  <p>What exactly is going wrong here? </p>