Skip to content

Weights

popinn.FixedWeights ¤

Static (non-trainable) per-term loss weights.

Fields:

  • values (dict): Mapping from term name to its scalar weight, keyed by the set of corresponding ResidualTerm.name strings.
Source code in src/popinn/loss.py
class FixedWeights(AbstractWeights):
    """
    Static (non-trainable) per-term loss weights.

    **Fields**:

    - `values` (`dict`): Mapping from term name to its scalar weight, keyed by the set of corresponding `ResidualTerm.name` strings.
    """

    values: dict = eqx.field(static=True)

    def combine(self, residuals: dict) -> Float[Array, ""]:
        """
        Combine per-term scalar losses into the weighted sum.

        Args:
            residuals (dict): A mapping from each `ResidualTerm.name` to that term's scalar
                value.

        Returns:
            (Float[Array, '']): The weighted sum over all loss terms.
        """
        return sum(self.values[k] * residuals[k] for k in self.values.keys())
combine(residuals) ¤

Combine per-term scalar losses into the weighted sum.

Parameters:

Name Type Description Default
residuals dict

A mapping from each ResidualTerm.name to that term's scalar value.

required

Returns:

Type Description
jaxtyping.Float[jax.Array, '']

The weighted sum over all loss terms.

Source code in src/popinn/loss.py
def combine(self, residuals: dict) -> Float[Array, ""]:
    """
    Combine per-term scalar losses into the weighted sum.

    Args:
        residuals (dict): A mapping from each `ResidualTerm.name` to that term's scalar
            value.

    Returns:
        (Float[Array, '']): The weighted sum over all loss terms.
    """
    return sum(self.values[k] * residuals[k] for k in self.values.keys())