Last active
April 15, 2016 08:12
-
-
Save techedlaksh/2326c69762c911dc573281f0bc780f35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
Author: Laksh Arora | |
Program: SOFTMAX.PY | |
Date: Friday, April 15 2016 | |
Description: Simple softmax function. | |
""" | |
import numpy as np | |
npa = np.array | |
def softmax(w, t = 1.0): | |
e = np.exp(npa(w) / t) | |
# can handle 2-D array too! | |
dist = e / e.sum(axis=0) | |
return dist | |
if __name__ == '__main__': | |
w = np.array([1.0, 2.0, 3.0]) | |
print softmax(w) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment