Skip to content

Instantly share code, notes, and snippets.

@jainakshansh
Created December 22, 2018 18:27
Show Gist options
  • Save jainakshansh/e6d2f222d8597ffa83c5fadf5c71cbe9 to your computer and use it in GitHub Desktop.
Save jainakshansh/e6d2f222d8597ffa83c5fadf5c71cbe9 to your computer and use it in GitHub Desktop.
The Softmax Algorithm for Multi-class Classification - Facebook Udacity PyTorch Challenge
import numpy as np
def softmax(L):
expL = np.exp(L)
sumExpL = sum(expL)
result = []
for i in expL:
result.append(i * 1.0 / sumExpL)
return result
L = [5, 6, 7]
print(softmax(L))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment