首页 > 其他 > 详细

softmax函数

时间:2019-04-22 13:22:33      阅读:94      评论:0      收藏:0      [点我收藏+]
#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函数

原文:https://www.cnblogs.com/smallredness/p/10749130.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!