TensorDictBase#
The methods of TensorDictBase are shared by every tensordict class and
by tensorclasses. They are listed by task in Methods by task,
with one page for each method.
- class tensordict.TensorDictBase(*args, **kwargs)#
The abstract base class of every tensordict.
TensorDict,LazyStackedTensorDict,PersistentTensorDictand the other tensordict classes subclass it, and tensorclasses have the same methods. You do not create aTensorDictBase: use it in type hints and inisinstancechecks. A tensorclass is not an instance of it: useis_tensor_collection()to accept both. The methods are listed by task in Methods by task.Examples
>>> import torch >>> from tensordict import TensorDict, TensorDictBase, lazy_stack >>> td = TensorDict(a=torch.zeros(3), batch_size=[3]) >>> isinstance(td, TensorDictBase), isinstance(lazy_stack([td, td]), TensorDictBase) (True, True)