INNER CODE UNIT · Python
aux_kl_loss
lucidrains/vector-quantize-pytorch · vector_quantize_pytorch/binary_mapper.py:82
aux_kl_loss = F.relu(kl_div - self.kl_loss_threshold)
if reduce_aux_kl_loss:
return aux_kl_loss.mean()
return inverse_pack_lead_dims(aux_kl_loss, '*')
def log_prob(
self,
logits,
*,
indices = None,
one_hot = None,
sum_bits = True
):
assert exists(indices) ^ exists(one_hot), 'either indices or one_hot must be provided'
if exists(one_hot):