File tree 2 files changed +17
-0
lines changed 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -722,6 +722,9 @@ Since each transform uses a ``"in_keys"``/``"out_keys"`` set of keyword argument
722
722
also easy to root the transform graph to each component of the observation data (e.g.
723
723
pixels or states etc).
724
724
725
+ Forward and inverse transforms
726
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
727
+
725
728
Transforms also have an ``inv `` method that is called before
726
729
the action is applied in reverse order over the composed transform chain:
727
730
this allows to apply transforms to data in the environment before the action is taken
@@ -733,6 +736,20 @@ in the environment. The keys to be included in this inverse transform are passed
733
736
734
737
>>> env.append_transform(DoubleToFloat(in_keys_inv=["action"])) # will map the action from float32 to float64 before calling the base_env.step
735
738
739
+ The way ``in_keys `` relates to ``in_keys_inv `` can be understood by considering the base environment as the "inner" part
740
+ of the transform. In constrast, the user inputs and outputs to and from the transform are to be considered as the
741
+ outside world. The following figure shows what this means in practice for the :class: `~torchrl.envs.RenameTransform `
742
+ class: the input ``TensorDict `` of the ``step `` function must have the ``out_keys_inv `` listed in its entries as they
743
+ are part of the outside world. The transform changes these names to make them match the names of the inner, base
744
+ environment using the ``in_keys_inv ``. The inverse process is executed with the output tensordict, where the ``in_keys ``
745
+ are mapped to the corresponding ``out_keys ``.
746
+
747
+ .. figure :: /_static/img/rename_transform.png
748
+
749
+ Rename transform logic
750
+
751
+
752
+
736
753
Cloning transforms
737
754
~~~~~~~~~~~~~~~~~~
738
755
You can’t perform that action at this time.
0 commit comments