TensorDictBase.is_locked#
- property TensorDictBase.is_locked: bool#
Trueif the tensordict is locked.A locked tensordict raises
RuntimeErroron any operation that adds, removes or renames an entry, or that replaces a leaf with a new tensor. Writes into the existing leaves still work. Seelock_().Setting
td.is_locked = Truecallslock_(), andtd.is_locked = Falsecallsunlock_().Examples
>>> from tensordict import TensorDict >>> td = TensorDict({"a": 0}) >>> td.is_locked False >>> td.is_locked = True >>> td.is_locked True
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.