peal.training.criterions.latent_convexity_criterion¶
- peal.training.criterions.latent_convexity_criterion(model, y_pred, y_target, latent_code=None)[source]¶
Mixup in the penultimate feature space (latent-convexity regulariser).
Pairs every latent code with a randomly permuted partner, interpolates the codes and the one-hot targets with a uniform
lamper sample, pushes the mixed codes throughmodel.get_last_layer()and scores the result withcross_entropy_criterion().y_predis unused;latent_codemust be the[N, D]activations the trainer extracted for the batch.- Returns:
Scalar loss.
- Return type: