requires_grad#
- metatensor.requires_grad(tensor: TensorMap, requires_grad: bool = True) TensorMap [source]#
Set
requires_grad
on all arrays (blocks and gradients of blocks) in thistensor
to the provided value.This is mainly intended for torch arrays, and will warn if trying to set
requires_grad=True
with numpy arrays.
- metatensor.requires_grad_block(block: TensorBlock, requires_grad: bool = True) TensorBlock [source]#
Set
requires_grad
on the values and all gradients in thisblock
to the provided value.This is mainly intended for torch arrays, and will warn if trying to set
requires_grad=True
with numpy arrays.- Parameters:
block (TensorBlock) –
TensorBlock
to modifyrequires_grad (bool) – new value for
requires_grad
- Return type: