noGrad
noGrad, function
def const autodiff pure noGrad(a: number): number
Returns a while removing it from automatic differentiation. The value is preserved,
but its gradient is zero.
Example
x = noGrad(1 + 2)
show scalar "noGrad value" with x
This outputs the following scalar:
| noGrad value |
|---|
| 3 |
Example (gradient mode)
Use mode:"gradient" to inspect gradients in an autodiff block. The
noGrad call removes its contribution to the gradient:
autodiff Scalar mode:"gradient" with
params y auto(1, 0)
loss = y * y + noGrad(y * y)
return loss
show scalar "dL/dy" with y
This outputs the following scalar:
| dL/dy |
|---|
| 2 |
Remarks
Inside an autodiff block, noGrad(a) behaves like a but
has zero gradient with respect to a.