from_zarr#
- tensordict.from_zarr(zarr_file, *, mode: str = 'r', auto_batch_size: bool = False, batch_dims: int | None = None, batch_size: Size | None = None, non_tensor_as_stack: bool = False, allow_pickle: bool | None = None) TensorDictBase#
Opens a zarr store as a
PersistentTensorDict.Requires
zarr>=3.1.1. SeeTensorDictBase.from_zarr.- Parameters:
zarr_file (str, path or zarr store) – the path to the zarr store (a directory), or a
zarr.abc.store.Storeinstance.- Keyword Arguments:
mode (str, optional) – how the store is opened:
"r"(read only),"r+"(read and write), and so on. Defaults to"r".auto_batch_size (bool, optional) – if
True, sets the batch size to the largest leading shape that all the entries share. Exclusive withbatch_size. Defaults toFalse.batch_dims (int, optional) – with
auto_batch_size, the maximum number of batch dimensions. Ignored withoutauto_batch_size, with aFutureWarningwhen it would change the result. Starting with TensorDict 0.17, the default will change to turning onauto_batch_sizewhenbatch_dimsis given, asfrom_dictdoes. Defaults toNone.batch_size (Size or list of int, optional) – the batch size of the result: the leading dimensions that all its entries share. Exclusive with
auto_batch_size. Defaults toNone, which reads the batch size thatto_zarr()stored, or computes it for a store written by another tool.non_tensor_as_stack (bool, optional) – if
True, a non-tensor array that tensordict did not write reads as aNonTensorStackof its rows when its leading dimensions equal the batch size. Defaults toFalse.allow_pickle (bool, optional) – whether to decode pickled non-tensor values.
Falserejects them.Truepermits them, only for data you trust.Nonepermits them with aFutureWarning. Starting with TensorDict 0.17, the default will change toallow_pickle=False. Defaults toNone.
- Returns:
A
PersistentTensorDictbacked by the store.