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函数的主要内容,如果未能解决你的问题,请参考以下文章

一个numpy数组的softmax函数逐行

神经网络中的 Softmax 函数(Python)

稳定的 Softmax 函数返回错误的输出

『科学计算』通过代码理解SoftMax多分类

python逻辑回归(logistic regression LR) 底层代码实现 BGD梯度下降算法 softmax多分类

tf.nn.softmax