Skip to content

Commit

Permalink
amend
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens committed Apr 23, 2024
1 parent 70315fb commit e7986ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions torchrl/record/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ def _call(self, tensordict: TensorDictBase) -> TensorDictBase:

def transform_observation_spec(self, observation_spec: TensorSpec) -> TensorSpec:
# Adds the pixel observation spec by calling render on the parent env
switch = False
if not self.enabled:
switch = True
self.switch()
parent = self.parent
td_in = TensorDict({}, batch_size=parent.batch_size, device=parent.device)
self._call(td_in)
Expand All @@ -495,6 +499,8 @@ def transform_observation_spec(self, observation_spec: TensorSpec) -> TensorSpec
device=obs.device, dtype=obs.dtype, shape=obs.shape
)
observation_spec[self.out_keys[0]] = spec
if switch:
self.switch()
return observation_spec

def switch(self, mode: str | bool = None):
Expand Down

0 comments on commit e7986ad

Please sign in to comment.