osl_dynamics.inference.schedules.kl_annealing_factor#

osl_dynamics.inference.schedules.kl_annealing_factor(epoch, curve, sharpness, n_epochs)#

Factor the KL loss is multiplied by.

The factor increases from 0 to 1 over n_epochs and is 1 after.

Parameters:
epochint

Epoch.

curvestr

'linear' for epoch / n_epochs or 'tanh' for 0.5 * tanh(sharpness * (epoch - 0.5 * n_epochs) / n_epochs) + 0.5.

sharpnessfloat

Sharpness of the 'tanh' curve.

n_epochsint

Number of annealing epochs.

Returns:
factorfloat