Sparsity Detection¶
asdex.jacobian_sparsity(f, input_shape)
¶
Detect global Jacobian sparsity pattern for f: R^n -> R^m.
Analyzes the computation graph structure directly, without evaluating any derivatives. The result is valid for all inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable
|
Function taking an array and returning an array. |
required |
input_shape
|
int | tuple[int, ...]
|
Shape of the input array. An integer is treated as a 1D length. |
required |
Returns:
| Type | Description |
|---|---|
SparsityPattern
|
SparsityPattern of shape |
asdex.hessian_sparsity(f, input_shape)
¶
Detect global Hessian sparsity pattern for f: R^n -> R.
Analyzes the Jacobian sparsity of the gradient function, without evaluating any derivatives. The result is valid for all inputs.
If f returns a squeezable shape like (1,) or (1, 1),
it is automatically squeezed to scalar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable
|
Scalar-valued function taking an array. |
required |
input_shape
|
int | tuple[int, ...]
|
Shape of the input array. An integer is treated as a 1D length. |
required |
Returns:
| Type | Description |
|---|---|
SparsityPattern
|
SparsityPattern of shape |