| 15 | |
| 16 | |
| 17 | class HiddenLayer(object): |
| 18 | def __init__(self, M1, M2): |
| 19 | self.M1 = M1 |
| 20 | self.M2 = M2 |
| 21 | W = np.random.randn(M1, M2) * np.sqrt(2.0 / M1) |
| 22 | b = np.zeros(M2) |
| 23 | self.W = tf.Variable(W.astype(np.float32)) |
| 24 | self.b = tf.Variable(b.astype(np.float32)) |
| 25 | self.params = [self.W, self.b] |
| 26 | |
| 27 | def forward(self, X): |
| 28 | return tf.nn.relu(tf.matmul(X, self.W) + self.b) |
| 29 | |
| 30 | |
| 31 | class ANN(object): |