def check_ref(self): t_x = chainer.Variable(self.context(self.t_x)) t_e = chainer.Variable(self.context(self.t_e)) x = chainer.Variable(self.context(self.x)) y, e = gravesnet.split_args(self.ngauss, x, t_x, t_e) p = gaussian_mixture_2d(*y) q = gaussian_mixture_2d_ref(*y) gradient_check.assert_allclose(p.data, q.data)
def forward_one_step(self, hidden_state, lstm_cells, x_data, t_x_data, t_e_data, train=True): x = chainer.Variable(x_data, volatile=not train) t_x = chainer.Variable(t_x_data, volatile=not train) t_e = chainer.Variable(t_e_data, volatile=not train) gps, y_e, hidden_state, lstm_cells = self.bottle_neck(hidden_state, lstm_cells, x_data, train) t_x = split_axis_by_widths(t_x, [1, 1]) gi, e = (gps + tuple(t_x)), (y_e, t_e) p = gaussian_mixture_2d_ref(*gi) loss = concat_losses(p, e) return hidden_state, lstm_cells, loss
def loss_func(m, y, t_x, t_e): x, e = split_args(m, y, t_x, t_e) p = gaussian_mixture_2d_ref(*x) return concat_losses(p, e)