fusionlab.params.resolve_physical_param

fusionlab.params.resolve_physical_param(param, name=None, *, serialize=False, status=None, param_type=None, log_transform=None, non_negative=None, trainable=None, **additional_kwargs)[source]

Normalize a physical-parameter descriptor with enhanced flexibility.

The helper converts param into:

  • A concrete value (float/tf.Tensor) for runtime use

  • A parameter wrapper (BaseLearnable/BaseFixed) when appropriate

  • A JSON-serializable dict when serialize=True

Parameters:
  • param (float | int | BaseLearnable | BaseFixed | str | Dict) –

    Raw descriptor. Can be:

    • Plain number: treated as fixed or learnable based on status

    • Wrapped parameter (BaseLearnable/BaseFixed): forwarded as-is

    • String: “learnable” or “fixed” to create wrapper with defaults

    • Dict: configuration for parameter creation

  • name (str, optional) –

    Parameter identifier used for:

    • Variable naming in TensorFlow backend

    • Type inference when creating wrappers

  • serialize (bool, default False) – Return configuration dict instead of concrete value.

  • status ({'learnable', 'fixed', 'auto', None}, optional) –

    Global override:

    • ’learnable’: force creation of learnable wrapper

    • ’fixed’: force creation of fixed wrapper

    • ’auto’: infer from param type

    • None: use param’s inherent behavior

  • param_type (str, optional) – Explicit parameter type. Overrides name-based inference. Options: ‘K’, ‘Ss’, ‘Q’, ‘MV’, ‘Kappa’, ‘GammaW’, ‘HRef’

  • log_transform (bool, optional) – Force log-space transformation for positivity.

  • non_negative (bool, optional) – Force non-negativity constraint.

  • trainable (bool, optional) – Override trainable flag (only for learnable params).

  • **additional_kwargs – Additional parameters passed to wrapper constructors.

Returns:

Concrete value, wrapper instance, or serialized configuration.

Return type:

Tensor | float | Dict | BaseLearnable | BaseFixed

Raises:
  • TypeError – If param is of unsupported type.

  • ValueError – If parameter type cannot be inferred or constraints are violated.

Examples

>>> from fusionlab.params import resolve_physical_param
>>> # Basic usage with type inference from name
>>> resolve_physical_param(1e-4, name="K", status="learnable")
LearnableK(initial_value=0.0001, trainable=True)
>>> # Explicit parameter type
>>> resolve_physical_param(0.5, param_type="MV", status="learnable")
LearnableMV(initial_value=0.5, trainable=True)
>>> # Fixed parameter with custom constraints
>>> resolve_physical_param(9810.0, param_type="GammaW", non_negative=True)
FixedGammaW(value=9810.0, non_negative=True)
>>> # From configuration dict
>>> config = {"class": "LearnableK", "initial_value": 0.5, "trainable": True}
>>> resolve_physical_param(config)
LearnableK(initial_value=0.5, trainable=True)
>>> # Serialization
>>> k = LearnableK(0.5)
>>> resolve_physical_param(k, serialize=True)
{'class': 'LearnableK', 'initial_value': 0.5, ...}