elicit.losses module#
- elicit.losses.compute_loss_components(elicited_statistics)[source]#
Computes the single loss components used for computing the discrepancy between the elicited statistics. This computation depends on the method as specified in the ‘combine-loss’ argument.
- Parameters:
- elicited_statisticsdict
dictionary including the elicited statistics.
- glob_dictdict
dictionary including all user-input settings.
- expertbool
if workflow is run to simulate a pre-specified ground truth; expert is set as ‘True’. As consequence the files are saved in a special ‘expert’ folder.
- Returns:
- loss_comp_resdict
dictionary including all loss components which will be used to compute the discrepancy.
- elicit.losses.compute_discrepancy(loss_components_expert, loss_components_training, targets)[source]#
Computes the discrepancy between all loss components using a specified discrepancy measure and returns a list with all loss values.
- Parameters:
- loss_components_expertdict
dictionary including all loss components derived from the expert-elicited statistics.
- loss_components_trainingdict
dictionary including all loss components derived from the model simulations. (The names (keys) between loss_components_expert and loss_components_training must match)
- glob_dictdict
dictionary including all user-input settings.
- Returns:
- loss_per_componentlist
list of loss value for each loss component
- elicit.losses.compute_loss(training_elicited_statistics, expert_elicited_statistics, epoch, targets)[source]#
Wrapper around the loss computation from elicited statistics to final loss value.
- Parameters:
- training_elicited_statisticsdict
dictionary containing the expert elicited statistics.
- expert_elicited_statisticsdict
dictionary containing the model-simulated elicited statistics.
- global_dictdict
global dictionary with all user input specifications.
- epochint
epoch .
- Returns:
- total_lossfloat
total loss value.
- elicit.losses.L2(loss_component_expert, loss_component_training, axis=None, ord='euclidean')[source]#
Wrapper around tf.norm that computes the norm of the difference between two tensors along the specified axis. Used for the correlation loss when priors are assumed to be independent
- Parameters:
- correlation_trainingA Tensor.
- axisAny or None
Axis along which to compute the norm of the difference. Default is None.
- ordint or str
Order of the norm. Supports ‘euclidean’ and other norms supported by tf.norm. Default is ‘euclidean’.
- class elicit.losses.MMD2(kernel: str = 'energy', sigma: int = None, **kwargs)[source]#
Bases:
object
Computes the biased, squared maximum mean discrepancy
- Parameters:
- kernelstr
kernel type used for computing the MMD such as “gaussian”, “energy” The default is “energy”.
- sigmaint, optional
Variance parameter used in the gaussian kernel. The default is None.
- **kwargskeyword arguments
Additional keyword arguments.
- __init__(kernel: str = 'energy', sigma: int = None, **kwargs)[source]#
Computes the biased, squared maximum mean discrepancy
- Parameters:
- kernelstr
kernel type used for computing the MMD such as “gaussian”, “energy” The default is “energy”.
- sigmaint, optional
Variance parameter used in the gaussian kernel. The default is None.
- **kwargskeyword arguments
Additional keyword arguments.
- __call__(x, y)[source]#
Computes the biased, squared maximum mean discrepancy of two samples
- Parameters:
- xtensor of shape (batch, num_samples)
preprocessed expert-elicited statistics. Preprocessing refers to broadcasting expert data to same shape as model-simulated data.
- ytensor of shape (batch, num_samples)
model-simulated statistics corresponding to expert-elicited statistics
- Returns:
- MMD2_meanfloat
Average biased, squared maximum mean discrepancy between expert- elicited and model simulated data.