Skip to content
Open
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
8 changes: 5 additions & 3 deletions torchrl/envs/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6673,8 +6673,8 @@ def _update(self, key, value, N) -> torch.Tensor:
)

mean = _sum / _count
std = (_ssq / _count - mean.pow(2)).clamp_min(self.eps).sqrt()
return (value - mean) / std.clamp_min(self.eps)
std = (_ssq / _count - mean.pow(2)).clamp_min(self.eps**2).sqrt()
return (value - mean) / std

def to_observation_norm(self) -> Compose | ObservationNorm:
"""Converts VecNorm into an ObservationNorm class that can be used at inference time.
Expand Down Expand Up @@ -6725,7 +6725,9 @@ def _get_loc_scale(self, loc_only=False, scale_only=False):
_ssq = self._td.get(_append_last(key, "_ssq"))
_count = self._td.get(_append_last(key, "_count"))
loc[key] = _sum / _count
scale[key] = (_ssq / _count - loc[key].pow(2)).clamp_min(self.eps).sqrt()
scale[key] = (
(_ssq / _count - loc[key].pow(2)).clamp_min(self.eps**2).sqrt()
)
if not scale_only:
loc = TensorDict(loc)
else:
Expand Down