Skip to content

Commit

Permalink
Hotfix - Return the new updated key in function _train (#46)
Browse files Browse the repository at this point in the history
* return the new updated key in _train

* Add regression test and update version

---------

Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
  • Loading branch information
theovincent and araffin authored Apr 12, 2024
1 parent fcd647e commit 42caa65
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sbx/crossq/crossq.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,6 @@ def one_update(i: int, carry: Dict[str, Any]) -> Dict[str, Any]:
update_carry["qf_state"],
update_carry["actor_state"],
update_carry["ent_coef_state"],
key,
update_carry["key"],
(update_carry["info"]["actor_loss"], update_carry["info"]["qf_loss"], update_carry["info"]["ent_coef_loss"]),
)
2 changes: 1 addition & 1 deletion sbx/sac/sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,6 @@ def one_update(i: int, carry: Dict[str, Any]) -> Dict[str, Any]:
update_carry["qf_state"],
update_carry["actor_state"],
update_carry["ent_coef_state"],
key,
update_carry["key"],
(update_carry["info"]["actor_loss"], update_carry["info"]["qf_loss"], update_carry["info"]["ent_coef_loss"]),
)
2 changes: 1 addition & 1 deletion sbx/td3/td3.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,6 @@ def one_update(i: int, carry: Dict[str, Any]) -> Dict[str, Any]:
return (
update_carry["qf_state"],
update_carry["actor_state"],
key,
update_carry["key"],
(update_carry["info"]["actor_loss"], update_carry["info"]["qf_loss"]),
)
2 changes: 1 addition & 1 deletion sbx/tqc/tqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def one_update(i: int, carry: Dict[str, Any]) -> Dict[str, Any]:
update_carry["qf2_state"],
update_carry["actor_state"],
update_carry["ent_coef_state"],
key,
update_carry["key"],
(
update_carry["info"]["qf1_loss"],
update_carry["info"]["qf2_loss"],
Expand Down
2 changes: 1 addition & 1 deletion sbx/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.0
0.15.0
3 changes: 3 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def test_sac_td3(tmp_path, model_class) -> None:
gradient_steps=1,
learning_rate=1e-3,
)
key_before_learn = model.key
model.learn(110)
# See issue #45
assert not np.allclose(key_before_learn, model.key)
check_save_load(model, model_class, tmp_path)


Expand Down

0 comments on commit 42caa65

Please sign in to comment.