Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def sample(self, inputs, states=None, max_len=20):
  2. out = []
  3. for i in range(max_len):
  4. lstm_out, states = self.lstm(inputs, states)
  5. lstm_out = torch.squeeze(lstm_out, 1)
  6. linear_out = self.linear(lstm_out)
  7. word = linear_out.max(1)[1]
  8. out.append(word.item())
  9. inputs = torch.unsqueeze(self.embed(word), 1)
  10.  
  11. return out
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement