MCPcopy Create free account
hub / github.com/PABannier/bark.cpp / softmax

Function softmax

bark.cpp:184–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184static void softmax(std::vector<float>& logits) {
185 // for numerical stability
186 float maxl = -INFINITY;
187 for (const auto& l : logits)
188 maxl = std::max(maxl, l);
189
190 // softmax
191 float sum = 0.0;
192 for (auto& l : logits) {
193 l = exp(l - maxl);
194 sum += l;
195 }
196
197 for (auto& l : logits)
198 l /= sum;
199}
200
201static bark_token gpt_multinomial_sample(
202 std::vector<float>& logits,

Callers 2

gpt_multinomial_sampleFunction · 0.70
gpt_argmax_sampleFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected