Softmax function
Softmax Function
- Raise e(the mathematical constant) to the power of each those numbers
- Sum up all the exponentails. This result is the denominator.
- Use each number’s exponential as its numerator.
- calculate numerator / denominator

import numpy as np
def softmax(xs):
return np.exp(xs)/sum(np.exp(xs))
xs = np.array([-1,0,3,5])
print(softmax(xs))
[0.002 0.006 0.118 0.874]
test = np.array([-4,2,5])
print(softmax(test))
test1 = np.array([-5,-4,-3,-2,-1,4])
np.set_printoptions(formatter={'float': '{: 0.8f}'.format})
print(softmax(test1))
[ 0.00011754 0.04742030 0.95246216]
[ 0.00012212 0.00033195 0.00090233 0.00245278 0.00666736 0.98952347]