MCPcopy Create free account
hub / github.com/ckd0817/LLM-Interview-Code / log_softmax

Function log_softmax

loss/EntropyLoss.py:44–71  ·  view source on GitHub ↗

数值稳定的 Log Softmax 函数 使用 Log-Sum-Exp 技巧保证数值稳定性。 公式: log_softmax(x) = x - log(sum(exp(x))) Args: logits: 未归一化的对数概率 [batch_size, num_classes] Returns: log_softmax: 对数概率 [batch_size, num_classes]

(logits)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 2

cross_entropy_lossFunction · 0.85
KL_divergenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected