softmax函数
Posted smallredness
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了softmax函数相关的知识,希望对你有一定的参考价值。
#include <vector>
#include <cmath> //math.h
std::vector<double> vsoftmax(std::vector<double> &v) {
double sum=0;
for(auto iter:v) {
sum+=exp(iter);
}
std::vector<double> res;
for(int i=0;i<v.size();i++) {
res.push_back(exp(v[i])/sum);
}
return res;
}
以上是关于softmax函数的主要内容,如果未能解决你的问题,请参考以下文章
python逻辑回归(logistic regression LR) 底层代码实现 BGD梯度下降算法 softmax多分类