Loss Functions

class stride.optimisation.loss.l2_distance.L2DistanceLoss(**kwargs)[source]

Bases: Operator

L2-Norm of the difference between observed and modelled data:

f = 1/2 ||modelled - observed||^2

async adjoint(d_fun, modelled, observed, **kwargs)[source]

Method defining the adjoint behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method will be called with positional arguments comprised of: the gradients of every output of the forward operation, followed by the arguments originally given when calling the forward method.

The adjoint method needs to return a gradient for each of its Variable inputs (or None if the variable does not needs_grad).

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs

property comms
async forward(modelled, observed, **kwargs)[source]

Method defining the forward behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method can take multiple inputs and produce multiple outputs. Outputs of this method should be of type Variable.

Positional and keyword arguments to forward are processed so that present variables are tracked.

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs

property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property worker
property zmq_context
class stride.optimisation.loss.functional.FunctionalValue(value, shot_id, residuals=None, **kwargs)[source]

Bases: Scalar

Container class for the calculated functional value and the residuals.

Parameters:
  • value (float) – Scalar value of the functional.

  • shot_id (int) – ID of the shot for which the value has been calculated.

  • residuals (Data) – Calculated residuals.