API reference · 13
Gradient
A device-resident derivative vector split into views that follow the ordered attributes it was differentiated with respect to.
Gradients are returned by differentiator.diff1 for scalar sources and are also assembled with every hessian.
gradient
gradient(wrt, hessian=None)Create a zero-filled gradient layout from static target attributes.
| Parameter | Type | Default | Description |
|---|---|---|---|
wrt |
list[attribute] |
required | Ordered, non-dynamic target attributes. |
hessian |
hessian or None |
None |
Optional parent that can assemble this gradient. |
Returns: new gradient.
Raises: ValueError when wrt contains a dynamic attribute.
compute
compute()Ask the parent hessian to assemble this gradient. A gradient without a parent is unchanged.
Example
target_state_loss_gradient.compute()
values = target_state_loss_gradient.value
Returns: None.
Properties
| Property | Type | Description |
|---|---|---|
hessian |
hessian or None |
Parent hessian responsible for numeric assembly. |
wrt |
list[attribute] |
Ordered target attributes. |
gradient_segments |
list[pycuda.gpuarray.GPUArray] |
Views into value, one per target in wrt. |
gradient_sizes |
list[int] |
Flat element count of each target segment. |
size |
int |
Total number of gradient elements. |
value |
pycuda.gpuarray.GPUArray |
Flat device-resident gradient values. |