forked from yusugomori/DeepLearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
executable file
·26 lines (16 loc) · 545 Bytes
/
utils.py
File metadata and controls
executable file
·26 lines (16 loc) · 545 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
''' '''
import numpy
numpy.seterr(all='ignore')
def sigmoid(x):
return 1. / (1 + numpy.exp(-x))
def softmax(x):
e = numpy.exp(x - numpy.max(x)) # prevent overflow
if e.ndim == 1:
return e / numpy.sum(e, axis=0)
else:
return e / numpy.array([numpy.sum(e, axis=1)]).T # ndim = 2
# # probability density for the Gaussian dist
# def gaussian(x, mean=0.0, scale=1.0):
# s = 2 * numpy.power(scale, 2)
# e = numpy.exp( - numpy.power((x - mean), 2) / s )
# return e / numpy.square(numpy.pi * s)