Rate this Page
★ ★ ★ ★ ★

TensorDictBase.to_json#

TensorDictBase.to_json(path, *, separator: str | None = None, lines: bool = False, **kwargs)#

Writes this TensorDict to a JSON file.

Parameters:

path (str or Path) – Path to the output JSON file.

Keyword Arguments:
  • separator (str, optional) – If provided, nested keys are joined with this separator. Defaults to None.

  • lines (bool, optional) – If True, writes in JSON Lines format. Defaults to False.

  • **kwargs – Additional keyword arguments forwarded to the JSON writer.

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