MCPcopy Create free account
hub / github.com/apache/singa / _train_one_batch_helper

Method _train_one_batch_helper

test/python/test_model.py:441–460  ·  view source on GitHub ↗
(self, dev, is_train, use_graph, sequential)

Source from the content-addressed store, hash-verified

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)

Callers 6

Calls 6

generate_dataMethod · 0.95
set_optimizerMethod · 0.95
get_paramsMethod · 0.95
numpy_train_one_batchMethod · 0.95
MLPClass · 0.70
compileMethod · 0.45

Tested by

no test coverage detected