首页 > 解决方案 > 在 tensorflow 中自定义 Softmax 激活函数

问题描述

我在 tensorflow 中构建了一个神经网络,它应该可以预测事件发生的概率。因此,作为输出函数,我通过了 softmax。我尝试自定义 softmax 函数,使所有(三个)类的概率总和为 1.05,最小(最大)概率为 0.02(0.99)。到目前为止,我有以下代码,但我不确定这是否正确

def custom_activation(x):
    return K.softmax(x)*(1 + 0.05)

有谁知道如何实现这个?

标签: pythontensorflowneural-networkcustomizationsoftmax

解决方案


推荐阅读