rl icon indicating copy to clipboard operation
rl copied to clipboard

[BUG] BoundedTensorSpec zero() returns out of bounds tensor

Open smorad opened this issue 1 year ago • 1 comments

Describe the bug

Calling zero() on the BoundedTensorSpec will return a tensor that is out of bounds. Would it make sense to return the minimum instead? Or raise an error?

My use case is initializing a nonzero recurrent state using TensorDictPrimer.

To Reproduce

from torchrl.data import BoundedTensorSpec
BoundedTensorSpec(minimum=1, maximum=2, shape=(3,)).zero()

>>> tensor([0., 0., 0.])

Checklist

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

smorad avatar Aug 11 '23 16:08 smorad

+1 for raising an error in this case, thanks for spotting this!

vmoens avatar Oct 09 '23 08:10 vmoens