如何在 Tensorflow 中针对单个 class 进行高特异性训练?
How can I train for high specificity for a single class in Tensorflow?
我有一个接收数据序列的 GRU 网络,并将其标记为 class 0 或 class 1。我希望模型对 class 具有高特异性0(至少 >= 0.8),同时确保它仍然具有良好的灵敏度(希望接近 0.5)。
我如何在 Tensorflow 中执行此操作?有没有办法让损失由单个class的特异性和敏感性的组合来确定?我真的不关心[=的预测准确性22=] 1,但是,在这种情况下,当预测 class 0 时预测正确非常重要,同时仍然有相当数量的 class 0 预测(至少预测 class 0 一半的时间标签也是 class 0)。
如有任何帮助,我们将不胜感激。
这是我到目前为止的相关代码:
states_concat = tf.concat(axis=1, values=states)
logits = tf.layers.dense(states_concat, n_outputs)
softmax = tf.nn.softmax(logits=logits)
xentropy = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y, logits=logits)
loss = tf.reduce_mean(xentropy)
#Set up the optimizer with gradient clipping to minimize the chance of exploding values
optimizer = tf.train.MomentumOptimizer(learning_rate=learning_rate, momentum=0.9, use_nesterov=True)
我回答了我自己的问题。
对于遇到此问题的任何其他人,其他有用的术语是精度和召回率,其中精度衡量:truePositives/(truePositives + falsePositives),而召回率衡量灵敏度。
对我有帮助的链接是:
https://www.quora.com/How-do-I-penalize-false-positive-in-deep-learning-tensorflow
https://www.tensorflow.org/api_docs/python/tf/nn/weighted_cross_entropy_with_logits
我有一个接收数据序列的 GRU 网络,并将其标记为 class 0 或 class 1。我希望模型对 class 具有高特异性0(至少 >= 0.8),同时确保它仍然具有良好的灵敏度(希望接近 0.5)。
我如何在 Tensorflow 中执行此操作?有没有办法让损失由单个class的特异性和敏感性的组合来确定?我真的不关心[=的预测准确性22=] 1,但是,在这种情况下,当预测 class 0 时预测正确非常重要,同时仍然有相当数量的 class 0 预测(至少预测 class 0 一半的时间标签也是 class 0)。
如有任何帮助,我们将不胜感激。
这是我到目前为止的相关代码:
states_concat = tf.concat(axis=1, values=states)
logits = tf.layers.dense(states_concat, n_outputs)
softmax = tf.nn.softmax(logits=logits)
xentropy = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=y, logits=logits)
loss = tf.reduce_mean(xentropy)
#Set up the optimizer with gradient clipping to minimize the chance of exploding values
optimizer = tf.train.MomentumOptimizer(learning_rate=learning_rate, momentum=0.9, use_nesterov=True)
我回答了我自己的问题。
对于遇到此问题的任何其他人,其他有用的术语是精度和召回率,其中精度衡量:truePositives/(truePositives + falsePositives),而召回率衡量灵敏度。
对我有帮助的链接是: https://www.quora.com/How-do-I-penalize-false-positive-in-deep-learning-tensorflow https://www.tensorflow.org/api_docs/python/tf/nn/weighted_cross_entropy_with_logits