Skip to content

[BUG] "Reproducible experiments" section in pendulum tutorial has inconsistent type parameter #3135

@valterschutz

Description

@valterschutz

Describe the bug

The tutorial at (https://docs.pytorch.org/rl/stable/tutorials/pendulum.html#reproducible-experiments-seeding) has the example

def _set_seed(self, seed: Optional[int]) -> None:
    rng = torch.manual_seed(seed)
    self.rng = rng

However, torch.manual does not accept None.

Additional context

As a side note, I wonder what the recommended way to handle randomness in environments is. My own preference would be to create a torch.Generator in _set_seed and then use it for all sources of randomness in _step. To my understanding, calling torch.manual_seed affects the global RNG of pytorch, not only the environment that we call it in.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions