(ML Specialization) (Code Lab)

A softmax function is used in both softmax regression and in Neural Networks when solving Multi-class Classification problems: converting a vector of values to a probability distribution. In simple terms, it converts values to probability.

Given possible classes for the output , the possibility of belongs to class is computed through activation function as:

where

def softmax(z):  
    """ Softmax converts a vector of values to a probability distribution.
    Args:
      z (ndarray (N,))  : input data, N features
    Returns:
      a (ndarray (N,))  : softmax of z
    """    
    
    e_z = np.exp(z)
    a = e_z / e_z.sum(axis = 0)
    
    return a