(self, dev, is_train, use_graph, sequential)
| 439 | np.testing.assert_array_almost_equal(tensor.to_numpy(out), np_out) |
| 440 | |
| 441 | def _train_one_batch_helper(self, dev, is_train, use_graph, sequential): |
| 442 | self.generate_data(dev) |
| 443 | model = MLP(num_classes=2) |
| 444 | model.set_optimizer(self.sgd) |
| 445 | model.compile([self.inputs], |
| 446 | is_train=is_train, |
| 447 | use_graph=use_graph, |
| 448 | sequential=sequential) |
| 449 | |
| 450 | self.get_params(model) |
| 451 | |
| 452 | out, loss = model(self.inputs, self.target) |
| 453 | np_out, np_loss = self.numpy_train_one_batch(self.data, self.label) |
| 454 | |
| 455 | np.testing.assert_array_almost_equal(tensor.to_numpy(out), np_out) |
| 456 | np.testing.assert_array_almost_equal(tensor.to_numpy(loss), np_loss) |
| 457 | np.testing.assert_array_almost_equal(tensor.to_numpy(self.w0), self.W0) |
| 458 | np.testing.assert_array_almost_equal(tensor.to_numpy(self.b0), self.B0) |
| 459 | np.testing.assert_array_almost_equal(tensor.to_numpy(self.w1), self.W1) |
| 460 | np.testing.assert_array_almost_equal(tensor.to_numpy(self.b1), self.B1) |
| 461 | |
| 462 | def test_forward_cpu(self): |
| 463 | self._forward_helper(cpu_dev, False, True, False) |
no test coverage detected