Skip to content

Commit

Permalink
add unit test for clear_param_diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
nitnelave committed Jun 22, 2016
1 parent 118c97f commit 892c78d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python/caffe/test/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def test_forward_backward(self):
self.net.forward()
self.net.backward()

def test_clear_param_diffs(self):
# Run a forward/backward step to have non-zero diffs
self.net.forward()
self.net.backward()
diff = self.net.params["conv"][0].diff
# Check that we have non-zero diffs
self.assertTrue(diff.max() > 0)
self.net.clear_param_diffs()
# Check that the diffs are now 0
self.assertTrue((diff == 0).all())

def test_inputs_outputs(self):
self.assertEqual(self.net.inputs, [])
self.assertEqual(self.net.outputs, ['loss'])
Expand Down

0 comments on commit 892c78d

Please sign in to comment.