首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在seq2seq_model的注意译码器中获取注意力值来绘制bleu分数

如何在seq2seq_model的注意译码器中获取注意力值来绘制bleu分数
EN

Stack Overflow用户
提问于 2016-08-22 18:12:54
回答 1查看 525关注 0票数 0

我正在研究一种语言翻译模式。

代码语言:javascript
复制
  1. I want to visualize data as mentioned in [http://www.wildml.com/2016/01/attention-and-memory-in-deep-learning-and-nlp/](http://www.wildml.com/2016/01/attention-and-memory-in-deep-learning-and-nlp/) using bleu score.
代码语言:javascript
复制
2.  
for a in xrange(num_heads):
    with variable_scope.variable_scope("Attention_%d" % a):
      y = linear(query, attention_vec_size, True)
      y = array_ops.reshape(y, [-1, 1, 1, attention_vec_size])
      # Attention mask is a softmax of v^T * tanh(...).
      s = math_ops.reduce_sum(
          v[a] * math_ops.tanh(hidden_features[a] + y), [2, 3])
      a = nn_ops.softmax(s)
      # Now calculate the attention-weighted vector d.
      d = math_ops.reduce_sum(
          array_ops.reshape(a, [-1, attn_length, 1, 1]) * hidden,
          [1, 2])
      ds.append(array_ops.reshape(d, [-1, attn_size]))
  return ds

如何修改代码以恢复可视化的"a“值?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-22 19:31:42

您首先需要在python列表中保存对这些张量的引用。然后将python列表传递给session.run函数。结果将是一个包含这些张量的numpy值的列表。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39086122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档