| 33 | |
| 34 | |
| 35 | class HiddenLayer(object): |
| 36 | def __init__(self, M1, M2, an_id): |
| 37 | self.id = an_id |
| 38 | self.M1 = M1 |
| 39 | self.M2 = M2 |
| 40 | W = np.random.randn(M1, M2) * np.sqrt(2.0 / M1) |
| 41 | b = np.zeros(M2) |
| 42 | self.W = theano.shared(W, 'W_%s' % self.id) |
| 43 | self.b = theano.shared(b, 'b_%s' % self.id) |
| 44 | self.params = [self.W, self.b] |
| 45 | |
| 46 | def forward(self, X): |
| 47 | return T.nnet.relu(X.dot(self.W) + self.b) |
| 48 | |
| 49 | |
| 50 | class ANN(object): |