def test_sum_hamiltonian_calls_np_dot_with_correct_args(self,mock_dot): hmc = HMCNeuron('fake_arg','fake_arg','fake_arg') momentum = np.array([.01,.02]) obj_error = 100 hmc.sum_hamiltonian(momentum,obj_error) assert(np.array_equal(mock_dot.call_args[0][0], momentum)) assert(np.array_equal(mock_dot.call_args[0][1], momentum * .5))
def test_sum_hamiltonian_example(self): """ The method sum_hamiltonian gives us the sum dot product of the momentum and the momentum transposed plus the objective function error. """ hmc = HMCNeuron('fake_arg','fake_arg','fake_arg') momentum = np.array([.01,.02]) # Fake initial momentum obj_error = 100 momentum = hmc.sum_hamiltonian(momentum,obj_error)
def test_sum_hamiltonian_calls_np_dot_with_momentum(self): hmc = HMCNeuron('fake_arg','fake_arg','fake_arg') momentum = np.array([.01,.02]) obj_error = 100.0 actual = hmc.sum_hamiltonian(momentum,obj_error) assert(isinstance(actual, float))
def test_sum_hamiltonian_calls_np_dot_once(self,mock_dot): hmc = HMCNeuron('fake_arg','fake_arg','fake_arg') momentum = np.array([.01,.02]) obj_error = 100 hmc.sum_hamiltonian(momentum,obj_error) assert(mock_dot.called_once)