adelie.diagnostic.gradient_norms#
- adelie.diagnostic.gradient_norms(grads: ndarray, betas: csr_matrix, duals: csr_matrix, lmdas: ndarray, *, constraints: list[ConstraintBase32 | ConstraintBase64] | None = None, groups: ndarray | None = None, alpha: float = 1, penalty: ndarray | None = None)[source]#
Computes the group-wise gradient norms.
The group-wise gradient norm is given by
wherewhere
is the gradient as inadelie.diagnostic.gradients()
, is the regularization, is the elastic net proportion, is the penalty factor, is the coefficient block for group , is the constraint function for group , and is the dual block for group .- Parameters:
- grads(L, p) or (L, p, K) ndarray
Gradients.
- betas(L, p) or (L, p*K) csr_matrix
Coefficient vectors
.- duals(L, d) csr_matrix
Dual vectors
.- lmdas(L,) ndarray
Regularization parameters
.- constraints(G,) list[Union[ConstraintBase32, ConstraintBase64]], optional
List of constraints for each group.
constraints[i]
is the constraint object corresponding to groupi
. Ifconstraints[i]
isNone
, then thei
th group is unconstrained. IfNone
, every group is unconstrained. Default isNone
.- groups(G,) ndarray, optional
List of starting indices to each group where G is the number of groups.
groups[i]
is the starting index of thei
th group. Ifglm
is of multi-response type, thengroups[i]
is the starting feature index of thei
th group. In either case,groups[i]
must then be a value in the range . Default isNone
, in which case it is set tonp.arange(p)
.- alphafloat, optional
Elastic net parameter
. It must be in the range . Default is1
.- penalty(G,) ndarray, optional
Penalty factor for each group in the same order as
groups
. It must be a non-negative vector. Default isNone
, in which case, it is set tonp.sqrt(group_sizes)
.
- Returns:
- norms(L, G) ndarray
Gradient norms.
See also