optax.tree_utils.tree_zeros_like

optax.tree_utils.tree_zeros_like#

optax.tree_utils.tree_zeros_like(tree: Any, dtype: str | type[Any] | dtype | SupportsDType | None = None) Any[source]#

Creates an all-zeros tree with the same structure.

Parameters:
  • tree โ€“ pytree.

  • dtype โ€“ optional dtype to use for the tree of zeros.

Returns:

an all-zeros tree with the same structure as tree.