gradnet.gradnet.DenseParameterization
- class gradnet.gradnet.DenseParameterization(num_nodes, budget, mask, cost_matrix, *, delta_sign='nonnegative', directed=False, strict_budget=False, cost_aggr_norm=1, rand_init_weights=True)[source]
Dense parameterization of a delta adjacency matrix.
Maintains a dense, trainable
delta_adj_rawand projects it to a constrained perturbationdeltathrough the following pipeline:raw -> (symmetrize?) -> (square?) -> mask -> normalize (when budget is set)
- Parameters:
num_nodes (int) – Number of nodes (matrix dimension).
budget (float | None) – Target cost-weighted p-norm for
delta. IfNone, skip normalization.mask (torch.Tensor) – Dense mask selecting active entries (1 for active, 0 for inactive). Nonzero diagonal entries are allowed but typically masked out by users.
cost_matrix (torch.Tensor) – Per-entry cost tensor for the normalization.
delta_sign (str, optional) – Sign constraint for the perturbation. One of
{"free", "nonnegative", "nonpositive"}.directed (bool, optional) – If
False, symmetrize before masking/normalizing.strict_budget (bool, optional) – If
True, always scale up/down to the exact budget; ifFalse, scale down only.cost_aggr_norm (int, optional) – Aggregation norm
pfor the cost-weighted p-norm.rand_init_weights (bool | float, optional) – Initialization mix coefficient
a. Cast to float and clamped to[0,1]. Initial raw parameters are set to(1 - a) * base + a * U(0,1), wherebaseis ones for strict budget mode and zeros otherwise.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Methods
extra_repr()Return the extra representation of the module.
forward([noise_amplitude])Project raw parameters to a constrained
deltamatrix.renorm_params()Renormalize the raw parameters to a DOF-aware scale.
set_initial_state(delta_adj_raw_0)Set the internal raw parameter and re-normalize.
Attributes
devicedtypetraining