title: Python: Define the softmax function
body: <pre><code>import numpy as np
  
  def softmax(x):
      row_num = x.shape[0]
      col_num = x.shape[1]
      for m in row_num:
          for n in col_num:
              new_x[m,n] = np.exp(x[m,n])/sum(x[:,n])
  
      return new_x
  
  logits = [1.0, 2.0, 3.0]
  logits2 = np.array([
      [1, 2, 3, 6],
      [2, 4, 5, 6],
      [3, 8, 7, 6]])
  
  print(softmax(logits1))
  print(softmax(logits2))
  </code></pre>
  
  <p>Above is the function for softmax (it is used to turn logits to probabilities)</p>
  
  <p>I want to obtain the solution shown as below:</p>
  
  <pre><code>[ 0.09003057  0.24472847  0.66524096]
  
  [
      [ 0.09003057  0.00242826  0.01587624  0.33333333]
      [ 0.24472847  0.01794253  0.11731043  0.33333333]
      [ 0.66524096  0.97962921  0.86681333  0.33333333]
  ]
  </code></pre>
  
  <p>However, error was revealed that "'int' object is not iterable".
  In addition, I want to see a more efficient code for this function with less complexity.</p>