MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / HiddenLayer

Class HiddenLayer

rl2/mountaincar/pg_theano.py:43–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42# so you can test different architectures
43class HiddenLayer:
44 def __init__(self, M1, M2, f=T.nnet.relu, use_bias=True, zeros=False):
45 if zeros:
46 W = np.zeros((M1, M2))
47 else:
48 W = np.random.randn(M1, M2) * np.sqrt(2. / M1)
49 self.W = theano.shared(W)
50 self.params = [self.W]
51 self.use_bias = use_bias
52 if use_bias:
53 self.b = theano.shared(np.zeros(M2))
54 self.params += [self.b]
55 self.f = f
56
57 def forward(self, X):
58 if self.use_bias:
59 a = X.dot(self.W) + self.b
60 else:
61 a = X.dot(self.W)
62 return self.f(a)
63
64
65# approximates pi(a | s)

Callers 2

__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected