分类模型的最后一层输出是什么?

说起这个问题,那就不可避免要提到激活函数,常见的有sigmoid和softmax,损失函数则是交叉熵。

通过help(roc_auc_score)得到官方的某个解释:

roc_auc_score(y_true, y_score, average='macro', sample_weight=None, max_fpr=None, multi_class='raise', labels=None)

    y_true : array-like of shape (n_samples,) or (n_samples, n_classes)
        True labels or binary label indicators. The binary and multiclass cases
        expect labels with shape (n_samples,) while the multilabel case expects
        binary label indicators with shape (n_samples, n_classes).
    
    y_score : array-like of shape (n_samples,) or (n_samples, n_classes)
        Target scores. In the binary and multilabel cases, these can be either
        probability estimates or non-thresholded decision values (as returned
        by `decision_function` on some classifiers). In the multiclass case,
        these must be probability estimates which sum to 1. The binary
        case expects a shape (n_samples,), and the scores must be the scores of
        the class with the greater label. The multiclass and multilabel
        cases expect a shape (n_samples, n_classes). In the multiclass case,
        the order of the class scores must correspond to the order of
        ``labels``, if provided, or else to the numerical or lexicographical
        order of the labels in ``y_true``.

其中y_score是目标分数,在二分类和多标签分类中,可以是概率估计或没有阈值的决策值,在多分类中,必须是概率估计(和为1).在多分类中,类别分数的顺序必须和标签的顺序一致。

下面用keras说明问题

输出的都是0.11665422, 0.5079881 , 0.37535766

都是和为1的结果,现在很少见到不是这样的结果了吧(除非用sigmoid,这个一般用在二分类吧)。

待续吧。。。

另外有相关问题可以加入QQ群讨论,不设微信群

QQ群:868373192 

语音图像视频深度-学习群

发布了250 篇原创文章 · 获赞 245 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/SPESEG/article/details/105322271
今日推荐