x = linear([inp] + attns, input_size, True)
# Run the RNN.
cell_output, state = cell(x, state)
# Run the attention mechanism.
if i == 0 and initial_state_attention:
with variable_scope.variable_scope(variable_scope.get_variable_scope(), reuse=True):
attns = attention(state)
else:
attns = attention(state)
with variable_scope.variable_scope("AttnOutputProjection"):
output = linear([cell_output] + attns, output_size, True)我的问题是,为什么我们需要将cell_output与as结合起来,而不是仅仅使用cell_output作为输出?
谢谢
发布于 2017-08-11 08:54:02
注意机制需要将更多的注意力放在某些特殊或特定的节点上。
这里,cell_output是数学中的一个矩阵。以及深度学习中节点的表示或组合。
因此,最后,如果您想给一些数据更多的优先级,那么您必须对您的cell_output进行一些更改。也就是说,我们是通过对原始矩阵(cell_output)进行一些级联、加法或点积运算来实现的。
let x = 5
and you want to make x = 7
then you can do x = x + 2(one way).
so that means you have make changes to your x variable.
same operation you are doing to apply attention to your hidden layers nodes or in your case cell_output.
here x is cell_output and 2 is attention output.如果您不对您的cell_output进行任何更改,那么您为什么要将注意力添加到您的输出表示上!
您可以直接将cell_output传递到最终层,而无需与注意矩阵相结合,也不需要应用注意。但是你需要知道为什么神经网络需要注意机制!
https://stackoverflow.com/questions/45630736
复制相似问题