geoprior.params.BaseLearnable#

class geoprior.params.BaseLearnable(initial_value, name, log_transform=False, trainable=True, **kws)[source]#

Bases: ABC

Abstract base for learnable physical parameters.

Parameters:
  • initial_value (float) – Initial numeric value for the parameter.

  • name (str) – Unique identifier for the variable.

  • log_transform (bool, optional) – If True, store in log-space for positivity constraint, by default False.

  • trainable (bool, optional) – If True, make variable trainable, by default True.

Variables:
  • initial_value (float) – The original provided value.

  • name (str) – Variable name in the computation graph.

  • log_transform (bool) – Whether to apply log transform.

  • trainable (bool) – Trainable flag for optimization.

Examples

>>> param = LearnableK(initial_value=0.5)
>>> value = param.get_value()
__init__(initial_value, name, log_transform=False, trainable=True, **kws)[source]#
Parameters:

Methods

__init__(initial_value, name[, ...])

from_config(config)

Re-instantiate from get_config().

get_config()

Return a JSON-serialisable dict for tf.keras.

get_value()

Retrieve parameter value.

__init__(initial_value, name, log_transform=False, trainable=True, **kws)[source]#
Parameters:
abstractmethod get_value()[source]#

Retrieve parameter value.

Returns:

Transformed parameter, e.g., \(\exp(log\_param)\) if log_transform is True.

Return type:

Union[Tensor, float]

get_config()[source]#

Return a JSON-serialisable dict for tf.keras.

Notes

Keras looks for this method during model.save() and keras.saving.serialization_lib.serialize_keras_object.

Return type:

dict[str, Any]

classmethod from_config(config)[source]#

Re-instantiate from get_config().

Keras passes config exactly as returned above.

Parameters:

config (dict[str, Any])

Return type:

BaseLearnable