TensorDictBase.swapdims#
- TensorDictBase.swapdims(axis0: int, axis1: int)#
Returns a tensordict with two batch dimensions swapped, as
transpose()does.swapaxesandswapdimsare aliases oftranspose(). It can be used as a context manager, astranspose()can.- Parameters:
Examples
>>> import torch >>> from tensordict import TensorDict >>> td = TensorDict({"a": torch.zeros(3, 4, 5)}, batch_size=[3, 4]) >>> print(td.swapaxes(0, 1).shape) torch.Size([4, 3])
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.