Shortcuts

is_tensor_collection

class tensordict.is_tensor_collection(datatype: Union[type, Any])

Checks if a data object or a type is a tensor container from the tensordict lib.

Returns:

True if the input is a TensorDictBase subclass, a tensorclass or an istance of these. False otherwise.

Examples

>>> is_tensor_collection(TensorDictBase)  # True
>>> is_tensor_collection(TensorDict())  # True
>>> @tensorclass
... class MyClass:
...     pass
...
>>> is_tensor_collection(MyClass)  # True
>>> is_tensor_collection(MyClass(batch_size=[]))  # True

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources