Skip to content

Commit

Permalink
Release/0.2.6.1 (#512)
Browse files Browse the repository at this point in the history
* Version 0.2.6

* Fix multiplying predictions when evaluate called mulitple times

* Add test

* Update changelog

* Update changelog

* Update CHANGELOG.md

* Bump version number

* Update CHANGELOG.md
  • Loading branch information
ethanwharris committed Feb 25, 2019
1 parent 1be9c30 commit 1b9c138
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added documentation about serialization.
- Added support for indefinite data loading. Iterators can now be run until complete independent of epochs or iterators can be refreshed during an epoch if complete.
- Added support for batch intervals in interval checkpointer

### Changed
- Changed the default behaviour of the std metric to compute the sample std, in line with torch.std
- Tqdm precision argument now rounds to decimal places rather than significant figures
Expand All @@ -34,6 +33,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed a bug in the cite decorator causing the citation to not show up correctly
- Fixed a memory leak in the mse primitive metric

## [0.2.6.1] - 2019-02-25
### Added
### Changed
### Deprecated
### Removed
### Fixed
- Fixed a bug where predictions would multiply when predict was called more than once

## [0.2.6] - 2018-12-19
### Added
### Changed
Expand Down
18 changes: 18 additions & 0 deletions tests/callbacks/test_aggregate_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,22 @@ def test_aggreate_predictions(self):
aggregator.on_end_validation(final_state)
self.assertTrue(list(final_state[tb.FINAL_PREDICTIONS].numpy()) == list(aggregate.numpy()))

def test_aggreate_predictions_multiple_calls(self):
aggregator = AggregatePredictions()

y_pred_1 = torch.Tensor([1,2,3])
y_pred_2 = torch.Tensor([3,4,5])

state_1 = {tb.Y_PRED: y_pred_1}
state_2 = {tb.Y_PRED: y_pred_2}

aggregator.on_step_validation(state_1)
self.assertTrue(list(aggregator.predictions_list[0].numpy()) == list(y_pred_1.numpy()))

aggregator.on_step_validation(state_2)
self.assertTrue(list(aggregator.predictions_list[1].numpy()) == list(y_pred_2.numpy()))

aggregator.on_end_epoch(state_2)
self.assertTrue(list(aggregator.predictions_list) == [])


4 changes: 4 additions & 0 deletions torchbearer/callbacks/aggregate_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ def on_step_validation(self, state):

def on_end_validation(self, state):
state[torchbearer.FINAL_PREDICTIONS] = torch.cat(self.predictions_list, 0)

def on_end_epoch(self, state):
super(AggregatePredictions, self).on_end_epoch(state)
self.predictions_list = []

0 comments on commit 1b9c138

Please sign in to comment.