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

Class HiddenLayer

rl2/cartpole/pg_tf.py:28–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27# so you can test different architectures
28class HiddenLayer:
29 def __init__(self, M1, M2, f=tf.nn.tanh, use_bias=True):
30 self.W = tf.Variable(tf.random_normal(shape=(M1, M2)))
31 self.use_bias = use_bias
32 if use_bias:
33 self.b = tf.Variable(np.zeros(M2).astype(np.float32))
34 self.f = f
35
36 def forward(self, X):
37 if self.use_bias:
38 a = tf.matmul(X, self.W) + self.b
39 else:
40 a = tf.matmul(X, self.W)
41 return self.f(a)
42
43
44# approximates pi(a | s)

Callers 2

__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected