2828 - Implementing behavior: seeding, reset and step.
2929- Transforming your environment inputs and outputs, and writing your own
3030 transforms;
31- - How to use :class:`~tensordict.TensorDict` to carry arbitrary data structures
31+ - How to use :class:`~tensordict.TensorDict` to carry arbitrary data structures
3232 through the ``codebase``.
3333
3434 In the process, we will touch three crucial components of TorchRL:
100100from tensordict .nn import TensorDictModule
101101from torch import nn
102102
103- from torchrl .data import Bounded , Composite , Unbounded
103+ from torchrl .data import BoundedTensorSpec , CompositeSpec , UnboundedContinuousTensorSpec
104104from torchrl .envs import (
105105 CatTensors ,
106106 EnvBase ,
@@ -403,14 +403,14 @@ def _reset(self, tensordict):
403403
404404def _make_spec (self , td_params ):
405405 # Under the hood, this will populate self.output_spec["observation"]
406- self .observation_spec = Composite (
407- th = Bounded (
406+ self .observation_spec = CompositeSpec (
407+ th = BoundedTensorSpec (
408408 low = - torch .pi ,
409409 high = torch .pi ,
410410 shape = (),
411411 dtype = torch .float32 ,
412412 ),
413- thdot = Bounded (
413+ thdot = BoundedTensorSpec (
414414 low = - td_params ["params" , "max_speed" ],
415415 high = td_params ["params" , "max_speed" ],
416416 shape = (),
@@ -426,23 +426,23 @@ def _make_spec(self, td_params):
426426 self .state_spec = self .observation_spec .clone ()
427427 # action-spec will be automatically wrapped in input_spec when
428428 # `self.action_spec = spec` will be called supported
429- self .action_spec = Bounded (
429+ self .action_spec = BoundedTensorSpec (
430430 low = - td_params ["params" , "max_torque" ],
431431 high = td_params ["params" , "max_torque" ],
432432 shape = (1 ,),
433433 dtype = torch .float32 ,
434434 )
435- self .reward_spec = Unbounded (shape = (* td_params .shape , 1 ))
435+ self .reward_spec = UnboundedContinuousTensorSpec (shape = (* td_params .shape , 1 ))
436436
437437
438438def make_composite_from_td (td ):
439439 # custom function to convert a ``tensordict`` in a similar spec structure
440440 # of unbounded values.
441- composite = Composite (
441+ composite = CompositeSpec (
442442 {
443443 key : make_composite_from_td (tensor )
444444 if isinstance (tensor , TensorDictBase )
445- else Unbounded (
445+ else UnboundedContinuousTensorSpec (
446446 dtype = tensor .dtype , device = tensor .device , shape = tensor .shape
447447 )
448448 for key , tensor in td .items ()
@@ -687,7 +687,7 @@ def _reset(
687687 # is of type ``Composite``
688688 @_apply_to_composite
689689 def transform_observation_spec (self , observation_spec ):
690- return Bounded (
690+ return BoundedTensorSpec (
691691 low = - 1 ,
692692 high = 1 ,
693693 shape = observation_spec .shape ,
@@ -711,7 +711,7 @@ def _reset(
711711 # is of type ``Composite``
712712 @_apply_to_composite
713713 def transform_observation_spec (self , observation_spec ):
714- return Bounded (
714+ return BoundedTensorSpec (
715715 low = - 1 ,
716716 high = 1 ,
717717 shape = observation_spec .shape ,
0 commit comments