def init_output_for(self, hidden):
"""
Creates a variable to be concatenated with previous target
embedding as input for the first rnn step. This is used
for the first decoding step when using the input_feed flag.
Returns:
--------
torch.Tensor(batch x hid_dim)
"""
if self.cell.startswith('LSTM'):
hidden = hidden[0]
_, batch, hid_dim = hidden.size()
output = torch.normal(hidden.data.new(batch, hid_dim).zero_(), 0.3)
return Variable(output, volatile=not self.training)
评论列表
文章目录