Utilities#
This page lists the names of tensordict.utils that the tensordict
module does not export: helpers for tensors and tensordicts, the types
that some methods return, and type aliases. Import them from
tensordict.utils. The names that tensordict also exports, such as
unravel_key() or assert_close(), are
on tensordict: containers and functions.
Tensor and tensordict helpers#
expand_right and expand_as_right add dimensions on the right of a
tensor, where broadcasting adds them on the left. isin and
remove_duplicates compare the values of one entry along a batch
dimension.
|
Expand a tensor on the right to match a desired shape. |
|
Expand a tensor on the right to match another tensor shape. |
|
Tests if each element of |
|
Removes indices duplicated in key along the specified dimension. |
Returned types#
The methods that have a return_early argument, such as
memmap(), return a
TensorDictFuture if you pass return_early=True.
tolist() returns
a LinkedList if you pass as_linked_list=True.
|
A custom future class for TensorDict multithreaded operations. |
|
A list of the values of a non-tensor entry that writes item assignments back to the tensordict. |
Type aliases#
DeviceType is the type of the device arguments, and IndexType
is the type of the indices that a tensordict accepts.
Debugging and profiling#
print_directory_tree prints the files of a directory, for example
the directory of a saved tensordict. timeit and logger are the
timer and the logger that tensordict uses in its own code. Buffer is
torch.nn.Buffer, kept here so that old
imports of tensordict.utils.Buffer still work.
|
Prints the directory tree starting from the specified path. |
|
Measures the time spent in a function or a block of code, by name. |
|
A kind of Tensor that should not be considered a model parameter. |
- tensordict.utils.logger#
The
logging.Loggernamed"tensordict". To show fewer messages from tensordict, raise the level of this logger, for examplelogging.getLogger("tensordict").setLevel(logging.WARNING).
See also#
tensordict: containers and functions: the functions of the
tensordictmodule.Save and load tensordicts:
memmap(return_early=True)and the files of a saved tensordict.