Custom softmax yielding infs

I’m trying to use a custom softmax function that can yield 0 probabilities:

logits = torch.exp(values / temp) - 1
probas = logits / torch.sum(logits)
probas[torch.isnan(probas)] = 0

But the exp function here yields infinities for values greater than 15 or so.