(self, x, h, Wx, Wh, b)
| 1201 | return out, h |
| 1202 | |
| 1203 | def step_forward(self, x, h, Wx, Wh, b): |
| 1204 | y2 = autograd.matmul(h, Wh) |
| 1205 | y1 = autograd.matmul(x, Wx) |
| 1206 | y = autograd.add(y2, y1) |
| 1207 | y = autograd.add_bias(y, b, axis=0) |
| 1208 | if self.nonlinearity == "tanh": |
| 1209 | y = autograd.tanh(y) |
| 1210 | elif self.nonlinearity == "relu": |
| 1211 | y = autograd.relu(y) |
| 1212 | else: |
| 1213 | raise ValueError |
| 1214 | return y |
| 1215 | |
| 1216 | def get_params(self): |
| 1217 | return { |