base#

Base class for obsidian objective functions

Classes

Objective([mo])

An objective function which is calculated from the model output(s) and input(s).

class obsidian.objectives.base.Objective(mo: bool = False)[source]#

Bases: MCMultiOutputObjective, MCAcquisitionObjective

An objective function which is calculated from the model output(s) and input(s).

_is_mo#

A flag indicating whether the final output is multi-output.

Type:

bool

abstract forward(samples: Tensor, X: Tensor | None = None) Tensor[source]#

Evaluate the multi-output objective on the samples.

Parameters:
  • samples – A sample_shape x batch_shape x q x m-dim Tensors of samples from a model posterior.

  • X – A batch_shape x q x d-dim Tensors of inputs.

Returns:

A sample_shape x batch_shape x q x m’-dim Tensor of objective values with m’ the output dimension. This assumes maximization in each output dimension).

This method is usually not called directly, but via the objectives.

Example

>>> # `__call__` method:
>>> samples = sampler(posterior)
>>> outcomes = multi_obj(samples)
classmethod load_state(obj_dict: dict)[source]#

Loads the objective from a state dictionary

output_shape(samples: Tensor) Tensor[source]#

Converts the output to the correct Torch shape based on the multi-output flag

save_state() dict[source]#

Saves the objective to a state dictionary