| 1170 | self.bidirectional = bidirectional |
| 1171 | |
| 1172 | def initialize(self, xs, h0): |
| 1173 | Wx_shape = (self.input_size, self.hidden_size) |
| 1174 | self.Wx = Tensor(shape=Wx_shape, requires_grad=True, stores_grad=True) |
| 1175 | self.Wx.gaussian(0.0, 1.0) |
| 1176 | |
| 1177 | Wh_shape = (self.hidden_size, self.hidden_size) |
| 1178 | self.Wh = Tensor(shape=Wh_shape, requires_grad=True, stores_grad=True) |
| 1179 | self.Wh.gaussian(0.0, 1.0) |
| 1180 | |
| 1181 | b_shape = (self.hidden_size,) |
| 1182 | self.b = Tensor(shape=b_shape, requires_grad=True, stores_grad=True) |
| 1183 | self.b.set_value(0.0) |
| 1184 | |
| 1185 | def forward(self, xs, h0): |
| 1186 | # xs: a tuple or list of input tensors |