Rate this Page
★ ★ ★ ★ ★

TensorDictBase.fromkeys#

classmethod TensorDictBase.fromkeys(keys: List[NestedKey], value: Any = 0)#

Creates a tensordict from a list of keys and a single value.

Parameters:
  • keys (list of NestedKey) – An iterable specifying the keys of the new dictionary.

  • value (compatible type, optional) – The value for all keys. Defaults to 0.

Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.