nnopinf.models.Model#

class nnopinf.models.Model(operators)[source]#

Bases: Module

Composite NN-OpInf model built from a list of operators.

forward(inputs, return_stiffness=False)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

set_scalings(input_scalings_dict, output_scalings)[source]#

Apply input and output scaling factors to each operator in the model.

Parameters:
  • input_scalings_dict (dict) – Mapping from variable name to the corresponding feature-wise input scaling vector.

  • output_scalings (tensor-like) – Feature-wise scaling vector for the model output.