-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add callback decorators * Update gan example with callback decorators * Update ignore file * Add tests for callback decorators
- Loading branch information
1 parent
67af6c0
commit da8a481
Showing
6 changed files
with
257 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import unittest | ||
|
||
import torchbearer.callbacks as callbacks | ||
|
||
|
||
class TestDecorators(unittest.TestCase): | ||
|
||
def test_on_start(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_start(example).on_start(state) == state) | ||
|
||
def test_on_start_epoch(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_start_epoch(example).on_start_epoch(state) == state) | ||
|
||
def test_on_start_training(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_start_training(example).on_start_training(state) == state) | ||
|
||
def test_on_sample(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_sample(example).on_sample(state) == state) | ||
|
||
def test_on_forward(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_forward(example).on_forward(state) == state) | ||
|
||
def test_on_criterion(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_criterion(example).on_criterion(state) == state) | ||
|
||
def test_on_backward(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_backward(example).on_backward(state) == state) | ||
|
||
def test_on_step_training(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_step_training(example).on_step_training(state) == state) | ||
|
||
def test_on_end_training(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_end_training(example).on_end_training(state) == state) | ||
|
||
def test_on_end_epoch(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_end_epoch(example).on_end_epoch(state) == state) | ||
|
||
def test_on_end(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_end(example).on_end(state) == state) | ||
|
||
def test_on_start_validation(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_start_validation(example).on_start_validation(state) == state) | ||
|
||
def test_on_sample_validation(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_sample_validation(example).on_sample_validation(state) == state) | ||
|
||
def test_on_forward_validation(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_forward_validation(example).on_forward_validation(state) == state) | ||
|
||
def test_on_end_validation(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_end_validation(example).on_end_validation(state) == state) | ||
|
||
def test_on_step_validation(self): | ||
def example(state): | ||
return state | ||
state = 'test' | ||
self.assertTrue(callbacks.on_step_validation(example).on_step_validation(state) == state) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.