EMCqMRI.core.base.base_likelihood_model module

class EMCqMRI.core.base.base_likelihood_model.Likelihood(config_object, ll_obj)[source]

Bases: abc.ABC

Base class for implementation of likelihood models

Parameters
  • config_object ([Configuration]) –

    Configuration object where following attributes must be specified:

    • args.engine.signal_model ([SignalModel])

  • ll_obj ([Likelihood]) – Circular reference to child of Likelihood object

gradients(signal, kappa, *extra_args)[source]

Computes the gradient of the signal model parameters with respect to the likelihood function. This function can be overriden if you want to define your own gradients (e.g. analytical, different shapes, etc.)

Parameters
  • signal ([torch.Tensor]) – Measured, input signal.

  • kappa ([list]) – A list of torch.Tensor parameters.

  • *extra_args ([tuple]) – Any additional parameters required by the signal model or likelihood model

Raises

TypeError – When kappa is not a list of torch.Tensor.

Returns

list of torch.Tensor with same number of elements as Kappa. Each element of the list is the gradient of each parameter with respect to the likelihood function.

Return type

([list])

abstract likelihood(signal, modeled_signal)[source]

Computes the loss, or error, based on the negative log likelihood function.

Parameters
  • signal ([torch.Tensor]) – Measured, input signal.

  • modeled_signal ([torch.Tensor]) – Tensor containing a simulated signal, generated with a signal model.

Raises

NotImplementedError – When the subclass does not override this method.

Returns

A scalar loss (i.e. error)

Return type

([torch.Float])