nnopinf.operators.QuadraticOperator#
- class nnopinf.operators.QuadraticOperator(n_outputs, acts_on, name='QuadraticOperator')[source]#
Bases:
Module\(f: x \mapsto H (x \otimes x)\)
Constructs a quadratic operator with a learnable matrix \(H\) that acts on the Kronecker product of the state with itself.
- Parameters:
n_outputs (int) – Output dimension of the operator.
acts_on (nnopinf.Variable) – The state the operator acts on, i.e., the \(x\) in \(H (x \otimes x)\).
name (string) – Operator name. Used when saving to file.
- forward(inputs, return_jacobian=False)[source]#
Forward pass of operator
- Parameters:
inputs (dict(str, np.array)) – Dictionary of input data in the form of arrays referenced by the variable name, i.e., inputs[‘x’] = np.ones(3)
return_jacobian (bool, optional) – If True, return the Jacobian with respect to the state.
- set_scalings(input_scalings_dict, output_scaling)[source]#
Apply input and output scaling factors to the quadratic operator.
- Parameters:
input_scalings_dict (dict) – Mapping from variable name to the corresponding feature-wise input scaling vector.
output_scaling (tensor-like) – Feature-wise scaling vector for the operator output.