original_docstring: Guided attention. Refer to page 3 on the paper.
docstring: Guided attention. Refer to page 3 on the paper.
docstring_tokens: Guided attention . Refer to page 3 on the paper .
code: def guided_attention(N, T, g=0.2):
      '''Guided attention. Refer to page 3 on the paper.'''
      W = np.zeros((N, T), dtype=np.float32)
      for n_pos in range(W.shape[0]):
          for t_pos in range(W.shape[1]):
              W[n_pos, t_pos] = 1 - np.exp(-(t_pos / float(T) - n_pos / float(N)) ** 2 / (2 * g * g))
      return W
code_tokens: def guided_attention ( N , T , g = 0.2 ) : W = np . zeros ( ( N , T ) , dtype = np . float32 ) for n_pos in range ( W . shape [ 0 ] ) : for t_pos in range ( W . shape [ 1 ] ) : W [ n_pos , t_pos ] = 1 - np . exp ( - ( t_pos / float ( T ) - n_pos / float ( N ) ) ** 2 / ( 2 * g * g ) ) return W
short_docstring: Guided attention.
short_docstring_tokens: Guided attention .
comment: '''Guided attention. Refer to page 3 on the paper.'''