【发布时间】:2018-05-28 02:31:32
【问题描述】:
我现在正在复制以下模型,该模型输出 action 并使用 filter 过滤不合适的候选人。
https://arxiv.org/abs/1702.03274
在这个模型中,输出在最后一个 softmax 层之后被过滤。让我们假设action_size==3。因此,dense & asoftmax 层之后的输出如下所示。
output: [0.1, 0.7, 0.2]
filter: [0, 1, 1]
output*filter: [0, 0.7, 0.2]
但在 pytorch 中,logsoftmax 与 NLLLoss 是首选。所以我的输出如下所示。这没有意义。
output: [-5.4, -0.2, -4.9]
filter: [0, 1, 1]
output*filter: [0, -0.2, -4.9]
所以pytoroch不推荐vanilla Softmax。我应该如何应用面具来消除特定的动作?
或者是否有任何带有 vanilla Softmax 的分类交叉熵损失函数?
此模块不能直接与 NLLLoss 一起使用,它期望在 Softmax 和自身之间计算 Log。改用 Logsoftmax(它更快并且具有更好的数值特性)。 http://pytorch.org/docs/master/nn.html#torch.nn.Softmax
【问题讨论】:
标签: deep-learning pytorch