Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Now targetting torch version 1.12, up from 1.11.
- `OnnxExporter` accepts a `device` argument to enable tracing on other devices.
- `FinalRewardTestCheck` can now be configured with another key and to use windowed data.

### Deprecations

Expand Down
12 changes: 11 additions & 1 deletion emote/callbacks/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ def __init__(
callback: LoggingMixin,
cutoff: float,
test_length: int,
key: str = "training/scaled_reward",
use_windowed: bool = False,
):
super().__init__(cycle=test_length)
self._cb = callback
self._cutoff = cutoff
self._key = key
self._use_windowed = use_windowed

def end_cycle(self):
reward = self._cb.scalar_logs["training/scaled_reward"]
if self._use_windowed:
data = self._cb.windowed_scalar[self._key]
reward = sum(data) / len(data)
else:
reward = self._cb.scalar_logs[self._key]

if reward < self._cutoff:
raise Exception(f"Reward too low: {reward}")

raise TrainingShutdownException()