2016-08-22 3 views
0

言語変換モデルを作成しています。
1. bleuスコアを使用してhttp://www.wildml.com/2016/01/attention-and-memory-in-deep-learning-and-nlp/に記載されているようにデータを視覚化したいと思います。seq2seq_modelのattentionデコーダの注意値にアクセスしてbleuスコアをプロットする方法

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」値を視覚化するためのコードを修正する方法はありますか?

答えて

0

まず、これらのテンソルへの参照をPythonリストに保存する必要があります。そして、pythonリストをsession.run関数に渡します。結果は、それらのテンソルのnumpy値を持つリストになります。

関連する問題