【问题标题】:Cutoff on Neural Network regression predictions神经网络回归预测的截止值
【发布时间】:2016-12-20 07:56:11
【问题描述】:

上下文:我有一组文档,每个文档都有两个关联的概率值:属于 A 类的概率或属于 B 类的概率。这些类是互斥的,并且概率加起来为一个。因此,例如文档 D 具有与基本事实相关联的概率 (0.6, 0.4)。

每个文档都由它包含的术语的 tfidf 表示,从 0 标准化为 1。我还尝试了 doc2vec(标准化形式 -1 到 1)和其他几种方法。

我构建了一个非常简单的神经网络来预测这个概率分布。

  • 具有与特征一样多的节点的输入层
  • 一个节点的单隐藏层
  • 具有 softmax 和两个节点的输出层
  • 交叉熵损失函数
  • 我还尝试了不同的更新函数和学习率

这是我使用 nolearn 编写的代码:

net = nolearn.lasagne.NeuralNet(
    layers=[('input', layers.InputLayer),
        ('hidden1', layers.DenseLayer),
        ('output', layers.DenseLayer)],
    input_shape=(None, X_train.shape[1]),
    hidden1_num_units=1,
    output_num_units=2,
    output_nonlinearity=lasagne.nonlinearities.softmax,
    objective_loss_function=lasagne.objectives.binary_crossentropy,
    max_epochs=50,
    on_epoch_finished=[es.EarlyStopping(patience=5, gamma=0.0001)],
    regression=True,
    update=lasagne.updates.adam,
    update_learning_rate=0.001,
    verbose=2)
net.fit(X_train, y_train)
y_true, y_pred = y_test, net.predict(X_test)

我的问题是:我的预测有一个截止点,并且没有预测低于该点(查看图片以了解我的意思)。 This plot shows the difference between the true probability and my predictions。点越接近红线,预测越好。理想情况下,所有点都在线上。我该如何解决这个问题,为什么会这样?

编辑:实际上我通过简单地移除隐藏层解决了这个问题:

net = nolearn.lasagne.NeuralNet(
    layers=[('input', layers.InputLayer),
        ('output', layers.DenseLayer)],
    input_shape=(None, X_train.shape[1]),
    output_num_units=2,
    output_nonlinearity=lasagne.nonlinearities.softmax,
    objective_loss_function=lasagne.objectives.binary_crossentropy,
    max_epochs=50,
    on_epoch_finished=[es.EarlyStopping(patience=5, gamma=0.0001)],
    regression=True,
    update=lasagne.updates.adam,
    update_learning_rate=0.001,
    verbose=2)
net.fit(X_train, y_train)
y_true, y_pred = y_test, net.predict(X_test)

但我仍然不明白为什么我会遇到这个问题以及为什么移除隐藏层可以解决它。有什么想法吗?

这里是新的情节:

【问题讨论】:

    标签: neural-network theano lasagne nolearn


    【解决方案1】:

    我认为你的训练集输出值应该是 [0,1] 或 [1,0],
    [0.6,0.4] 不适合 softmax/Crossentropy 。

    【讨论】:

    • 我不明白为什么会有问题。据我所知,softmax 输出加起来为 1,交叉熵衡量两个概率分布之间的差异。
    猜你喜欢
    • 2015-07-05
    • 1970-01-01
    • 2017-09-01
    • 2019-01-27
    • 1970-01-01
    • 2020-02-07
    • 2021-09-13
    • 1970-01-01
    • 2017-12-02
    相关资源
    最近更新 更多