Загрузка
Context-manager that enables gradient calculation.
Enables gradient calculation, if it has been disabled via no_grad
or set_grad_enabled.
This context manager is thread local; it will not affect computation in other threads.
Also functions as a decorator.
>>> x = torch.tensor([1.], requires_grad=True)
>>> with torch.no_grad():
... with torch.enable_grad():
... y = x * 2
>>>
Self | F