TensorDictBase.is_non_tensor#
- TensorDictBase.is_non_tensor(key: NestedKey) bool#
Returns
Trueif the entry atkeyis non-tensor data.Non-tensor data is a
NonTensorDataor aNonTensorStack. Unlike the functionis_non_tensor(), which checks a value, this method checks the stored entry. This matters for a tensorclass, whosegetreturns the content of a non-tensor entry, not theNonTensorData.See also
Examples
>>> import torch >>> from tensordict import TensorDict >>> td = TensorDict({"obs": torch.zeros(4)}, []) >>> td = td.set_non_tensor("label", "cat") >>> td.is_non_tensor("label") True >>> td.is_non_tensor("obs") False
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.