TensorDictBase.rename#
- TensorDictBase.rename_(*names, **rename_map)#
Renames the batch dimensions of the tensordict in place and returns
self.Pass either the new names, one per batch dimension, or keyword arguments that map old names to new ones. The nested tensordicts get the new names for the batch dimensions they share with the tensordict.
- Parameters:
- Raises:
ValueError – if both
namesandrename_mapare passed, or neither (except on a tensordict with no batch dimension), or if a key ofrename_mapis not a name of the tensordict.
See also
rename(), which returns a renamed copy.Examples
>>> from tensordict import TensorDict >>> td = TensorDict(batch_size=[1, 2, 3, 4], names=list("abcd")) >>> td.rename_(c="g") is td True >>> td.names ['a', 'b', 'g', 'd'] >>> td.rename_(None).names [None, None, None, None]
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.