1
2
3
4 """ Activation functions for neural network nodes
5
6 Activation functions should implement the following API:
7
8 - _Eval(input)_: returns the value of the function at a given point
9
10 - _Deriv(input)_: returns the derivative of the function at a given point
11
12 The current Backprop implementation also requires:
13
14 - _DerivFromVal(val)_: returns the derivative of the function when its
15 value is val
16
17 In all cases _input_ is a float as is the value returned.
18
19 """
20 from Numeric import *
21
22
24 """ "virtual base class" for activation functions
25
26 """
28 return self.Eval(input)
29
30
32 """ the standard sigmoidal function """
33 - def Eval(self,input):
34 return 1./(1.+exp(-self.beta*input))
35
37 val = self.Eval(input)
38 return self.beta * val * (1. - val)
39
41 return self.beta * val * (1. - val)
42
45
47 """ the standard hyperbolic tangent function """
48 - def Eval(self,input):
49 v1 = exp(self.beta*input)
50 v2 = exp(-self.beta*input)
51 return (v1 - v2)/(v1 + v2)
52
54 val = self.Eval(input)
55 return self.beta * (1 - val*val)
56
58 return self.beta * (1 - val*val)
59
62