Skip to content
Open
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.3
hooks:
- id: autoflake
name: Remove unused variables and imports
Expand All @@ -18,7 +18,7 @@ repos:
files: \.py$

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 8.0.1
hooks:
- id: isort
name: (isort) Sorting import statements
Expand All @@ -27,8 +27,8 @@ repos:
types: [python]
files: \.py$

- repo: https://github.com/psf/black
rev: 23.12.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.0
hooks:
- id: black
name: (black) Format Python code
Expand All @@ -43,7 +43,7 @@ repos:
types: [jupyter]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.11"
rev: "v0.15.5"
hooks:
- id: ruff
args: ["--config", "pyproject.toml", "--fix", "./sheeprl"]
1 change: 0 additions & 1 deletion notebooks/dreamer_v3_imagination.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"import torchvision\n",
"from lightning.fabric import Fabric\n",
"from omegaconf import OmegaConf\n",
"from PIL import Image\n",
"\n",
"from sheeprl.algos.dreamer_v3.agent import build_agent\n",
"from sheeprl.data.buffers import SequentialReplayBuffer\n",
Expand Down
4 changes: 1 addition & 3 deletions sheeprl/algos/dreamer_v3/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def __init__(
layer_args={"kernel_size": 4, "stride": 2, "padding": 1, "bias": layer_norm_cls == nn.Identity},
activation=activation,
norm_layer=[layer_norm_cls] * stages,
norm_args=[
{**layer_norm_kw, "normalized_shape": (2**i) * channels_multiplier} for i in range(stages)
],
norm_args=[{**layer_norm_kw, "normalized_shape": (2**i) * channels_multiplier} for i in range(stages)],
),
nn.Flatten(-3, -1),
)
Expand Down
2 changes: 1 addition & 1 deletion sheeprl/algos/p2e_dv3/p2e_dv3_finetuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def main(fabric: Fabric, cfg: Dict[str, Any], exploration_cfg: Dict[str, Any]):
fabric.print("Decoder MLP keys:", cfg.algo.mlp_keys.decoder)
obs_keys = cfg.algo.cnn_keys.encoder + cfg.algo.mlp_keys.encoder

(world_model, _, actor_task, critic_task, target_critic_task, actor_exploration, _, player) = build_agent(
world_model, _, actor_task, critic_task, target_critic_task, actor_exploration, _, player = build_agent(
fabric,
actions_dim,
is_continuous,
Expand Down
3 changes: 1 addition & 2 deletions sheeprl/algos/sac/loss.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Based on "Soft Actor-Critic Algorithms and Applications": https://arxiv.org/abs/1812.05905
"""
"""Based on "Soft Actor-Critic Algorithms and Applications": https://arxiv.org/abs/1812.05905"""

from numbers import Number

Expand Down
20 changes: 8 additions & 12 deletions sheeprl/data/buffers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,10 @@ def to_tensor(
return buf

@typing.overload
def add(self, data: "ReplayBuffer", validate_args: bool = False) -> None:
...
def add(self, data: "ReplayBuffer", validate_args: bool = False) -> None: ...

@typing.overload
def add(self, data: Dict[str, np.ndarray], validate_args: bool = False) -> None:
...
def add(self, data: Dict[str, np.ndarray], validate_args: bool = False) -> None: ...

def add(self, data: "ReplayBuffer" | Dict[str, np.ndarray], validate_args: bool = False) -> None:
"""Add data to the replay buffer. If the replay buffer is full, then the oldest data is overwritten.
Expand Down Expand Up @@ -617,12 +615,10 @@ def __len__(self) -> int:
return self.buffer_size

@typing.overload
def add(self, data: "ReplayBuffer", validate_args: bool = False) -> None:
...
def add(self, data: "ReplayBuffer", validate_args: bool = False) -> None: ...

@typing.overload
def add(self, data: Dict[str, np.ndarray], validate_args: bool = False) -> None:
...
def add(self, data: Dict[str, np.ndarray], validate_args: bool = False) -> None: ...

def add(
self,
Expand Down Expand Up @@ -860,17 +856,17 @@ def __len__(self) -> int:
return self._cum_lengths[-1] if len(self._buf) > 0 else 0

@typing.overload
def add(self, data: "ReplayBuffer", env_idxes: Sequence[int] | None = None, validate_args: bool = False) -> None:
...
def add(
self, data: "ReplayBuffer", env_idxes: Sequence[int] | None = None, validate_args: bool = False
) -> None: ...

@typing.overload
def add(
self,
data: Dict[str, np.ndarray],
env_idxes: Sequence[int] | None = None,
validate_args: bool = False,
) -> None:
...
) -> None: ...

def add(
self,
Expand Down
2 changes: 1 addition & 1 deletion sheeprl/optim/rmsprop_tf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" RMSProp modified to behave like Tensorflow impl
"""RMSProp modified to behave like Tensorflow impl

Originally cut & paste from PyTorch RMSProp
https://github.com/pytorch/pytorch/blob/063946d2b3f3f1e953a2a3b54e0b34f1393de295/torch/optim/rmsprop.py
Expand Down
Loading