Fix softmax in perplexity.cpp
This commit is contained in:
parent
3a42193b3d
commit
f68345e9b1
1 changed files with 1 additions and 1 deletions
|
@ -9,7 +9,7 @@ std::vector<double> softmax(const std::vector<float>& logits) {
|
||||||
for (size_t i = 0; i < logits.size(); i++) {
|
for (size_t i = 0; i < logits.size(); i++) {
|
||||||
// Subtract the maximum logit value from the current logit value for numerical stability
|
// Subtract the maximum logit value from the current logit value for numerical stability
|
||||||
float logit = logits[i] - max_logit;
|
float logit = logits[i] - max_logit;
|
||||||
double exp_logit = std::exp(logit);
|
double exp_logit = std::exp((double)logit);
|
||||||
sum_exp += exp_logit;
|
sum_exp += exp_logit;
|
||||||
probs[i] = exp_logit;
|
probs[i] = exp_logit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue