fusionlab.params.resolve_physical_param

fusionlab.params.resolve_physical_param(param, name=None, *, serialize=False, status=None)[source]

Normalise a physical-parameter descriptor.

The helper converts param into

  • a concrete value (float / tf.Tensor) for use at run-time,

  • a BaseLearnable wrapper when the parameter should be trainable, or

  • a JSON-serialisable dict when serialize=True.

Parameters:
  • param (float | int | BaseLearnable | str) – Raw descriptor. A plain number is treated as fixed; a wrapped BaseLearnable is forwarded; the strings "learnable" / "fixed" are honoured when status=’learnable’.

  • name (str, optional) – Camel-case label ("K", "Ss", or "Q") required only when status=’learnable’ and param is numeric.

  • serialize (bool, default False) – Return a configuration dict instead of a concrete value. Used by :pyclass:`tf.keras.Model` when saving.

  • status ({{'learnable', 'fixed', None}}, optional) – Global override. 'learnable' forces numeric inputs to be wrapped; 'fixed' unwraps to raw numbers; None leaves each parameter untouched.

Returns:

Concrete value for computation or a serialisable mapping.

Return type:

Tensor | float | Dict

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

  • ValueError – If status=’learnable’ but name is not one of 'K', 'Ss', or 'Q'.

Examples

>>> from fusionlab.params import resolve_physical_param
>>> resolve_physical_param(1e-4, name="K", status="learnable")
LearnableK(initial_value=0.0001, trainable=True)
>>> k = LearnableK(0.5)
>>> resolve_physical_param(k, serialize=True)
{'learnable': True, 'initial_value': 0.5, 'class': 'LearnableK'}