(rontolisp) docs
← Functions

torch:set-data

(torch:set-data tensor value)

Replaces the tensor's data in place with value (a linalg array or a number) and returns the tensor. This is the parameter update of a training loop: it writes into the very tensor a module's fields already point at, so the layer keeps using it. The tape is untouched, so call it inside torch:no-grad, like torch.no_grad() around an optimizer step.