Optimization#

Loss functions

The following functions can be used as the loss_function argument for Metamer and MetamerCTF.

mse

Calculate the MSE between synth_rep and ref_rep.

l2_norm

Calculate the L2-norm of the difference between ref_rep and synth_rep.

relative_sse

Calculate the relative sum of squared errors between two tensors.

Loss function factories

The following functions return a function that can be used as a loss_function, as above.

portilla_simoncelli_loss_factory

Create the loss function required for PortillaSimoncelli metamer synthesis.

groupwise_relative_l2_norm_factory

Create loss function that computes groupwise relative L2 norm for synthesis.

Penalty functions

The following functions operate as penalties.

penalize_range

Calculate quadratic penalty on values outside of allowed_range.