#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;
}
原文地址:https://www.cnblogs.com/smallredness/p/10749130.html
时间: 2024-10-22 06:43:34