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