#216 · Deep Learning · Easy
⊣ Solve on deep-ml.comImplement the softmax function to predict dish selection probabilities for a Thanksgiving feast. Given a list of raw scores (logits) for each dish, apply the softmax function to convert them into a probability distribution that sums to 1.
import math
def softmax(logits: list[float]) -> list[float]:
max_logit = max(logits)
exps = [math.exp(x - max_logit) for x in logits]
total = sum(exps)
return [e / total for e in exps]