loss module

DIRESA loss classes/functions

Author:

Geert De Paepe

Email:

geert.de.paepe@vub.be

License:

MIT License

class loss.KLLoss(kl_weight)

KL weighted loss class KL weight is annealed by KLAnnealingCallback

__init__(kl_weight)
Parameters:

kl_weight – tensorflow variable with initial KL loss weight

call(_, z_mean_var)
Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • z_mean_var – list with mean and ln of the variance of the distribution

Returns:

weighted KL loss

class loss.LatentCovLoss(cov_weight)

Latent covariance loss class Latent covariance weight is annealed by AnnealingCallback

__init__(cov_weight)
Parameters:

cov_weight – tensorflow variable with initial covariance loss weight

call(_, latent)
Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • latent – batch of latent vectors

Returns:

weighted covariance loss

loss.mae_dist_loss(_, distances)

Absolute Error between original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

batch of absolute errors

loss.male_dist_loss(_, distances)

Absolute Error between logarithm of original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

batch of absolute logarithmic errors

loss.mape_dist_loss(_, distances)

Absolute Percentage Error between original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

batch of absolute percentage errors

loss.mse_dist_loss(_, distances)

Squared Error between original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

batch of squared errors

loss.msle_dist_loss(_, distances)

Squared Error between logarithm of original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

batch of squared logarithmic errors

loss.corr_dist_loss(_, distances)

Correlation loss between original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

1 - correlation coefficient

loss.corr_log_dist_loss(_, distances)

Correlation loss between logarithm of original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

1 - correlation coefficient (of logarithmic distances)

loss.loc_corr_dist_loss(_, distances)

Correlation loss between original and latent distances with location parameter

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

1 - correlation coefficient (of 50% closest distances in latent space)

loss.spear_dist_loss(_, distances)

Spearman correlation loss between original and latent distances

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

1 - Spearman correlation coefficient

loss.canberra_dist_loss(_, distances)

Canberra distance loss with location parameter https://github.com/richardARPANET/mlpy/blob/master/mlpy/canberra/c_canberra.c

Parameters:
  • _ – not used (loss functions need 2 params: the true and predicted values)

  • distances – batch of original and latent distances between twins

Returns:

Canberra distance (of 50% closest distances in latent space)