romtools.rom.neural_network_surrogate#

Functions

estimate_pairwise_lipschitz_constant(...[, ...])

Estimate the maximum pairwise Lipschitz slope from training data.

Classes

LipschitzConfig([enabled, ...])

Configuration for a hard Lipschitz constraint on the neural surrogate.

LipschitzNeuralNetworkQoiModel(parameters, qois)

Neural-network QoI surrogate with a spectral Lipschitz constraint.

NeuralNetworkQoiModelBuilderWithTrainingData(...)

Build a torch neural-network QoI surrogate from workflow training data.

class romtools.rom.neural_network_surrogate.LipschitzConfig(enabled=False, lipschitz_constant=None, safety_factor=1.1, spectral_norm_power_iterations=5, pairwise_distance_tolerance=1e-12, layer_lipschitz_constants=None)[source]#

Bases: object

Configuration for a hard Lipschitz constraint on the neural surrogate.

When enabled, spectral normalization constrains every linear operator to unit spectral norm and a scalar multiplier is applied to each layer. If lipschitz_constant is not supplied, the global constant is estimated from pairwise slopes in the transformed training coordinates and multiplied by safety_factor.

Parameters:
  • enabled (bool)

  • lipschitz_constant (float | None)

  • safety_factor (float)

  • spectral_norm_power_iterations (int)

  • pairwise_distance_tolerance (float)

  • layer_lipschitz_constants (Sequence[float] | None)

class romtools.rom.neural_network_surrogate.LipschitzNeuralNetworkQoiModel(parameters, qois, parameter_names=None, pod_energy_fraction=0.999999, max_pod_modes=None, network_config=None, lipschitz_config=None, normalize_parameters=True, normalize_targets=True)[source]#

Bases: NeuralNetworkQoiModel

Neural-network QoI surrogate with a spectral Lipschitz constraint.

Parameters:
  • parameters (np.ndarray)

  • qois (np.ndarray)

  • parameter_names (Optional[Sequence[str]])

  • pod_energy_fraction (float)

  • max_pod_modes (Optional[int])

  • network_config (Optional[NeuralNetworkConfig])

  • lipschitz_config (Optional[LipschitzConfig])

  • normalize_parameters (bool)

  • normalize_targets (bool)

class romtools.rom.neural_network_surrogate.NeuralNetworkQoiModelBuilderWithTrainingData(parameter_names, pod_energy_fraction=0.999999, max_pod_modes=None, network_config=None, lipschitz_config=None, normalize_parameters=True, normalize_targets=True)[source]#

Bases: object

Build a torch neural-network QoI surrogate from workflow training data.

The builder mirrors the POD controls used by the Gaussian-process surrogate while keeping neural-network architecture and optimization settings in NeuralNetworkConfig. A hard Lipschitz constraint can be enabled independently with LipschitzConfig.

Parameters:
  • parameter_names (Optional[Sequence[str]])

  • pod_energy_fraction (float)

  • max_pod_modes (Optional[int])

  • network_config (Optional[NeuralNetworkConfig])

  • lipschitz_config (Optional[LipschitzConfig])

  • normalize_parameters (bool)

  • normalize_targets (bool)

romtools.rom.neural_network_surrogate.estimate_pairwise_lipschitz_constant(parameters, targets, distance_tolerance=1e-12)[source]#

Estimate the maximum pairwise Lipschitz slope from training data.

Parameters:
  • parameters (ndarray)

  • targets (ndarray)

  • distance_tolerance (float)

Return type:

float