Loading...
Implement the softmax function for multi-class classification.
Given a list of logits (raw scores) z=[z1,z2,...,zk], compute the softmax probabilities:
softmax(zi)=∑j=1kezjezi
For numerical stability, subtract the maximum value from all logits before exponentiating: softmax(zi)=∑j=1kezj−max(z)ezi−max(z)
Return the probability distribution as a list, rounded to 4 decimal places.
logits = [2.0, 1.0, 0.1]
[0.6590, 0.2424, 0.0986]