From f1a799116159848dcaedc6e24f1dc8ec74db3b59 Mon Sep 17 00:00:00 2001 From: dhanajitb Date: Tue, 20 Nov 2018 02:30:57 +0530 Subject: [PATCH] converting prob into a cuda variable --- model.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/model.py b/model.py index 4cb9824..ae5d0e4 100644 --- a/model.py +++ b/model.py @@ -87,6 +87,8 @@ def forward(self, input_sequence, length): if self.word_dropout_rate > 0: # randomly replace decoder input with prob = torch.rand(input_sequence.size()) + if torch.cuda.is_available(): + prob=prob.cuda() prob[(input_sequence.data - self.sos_idx) * (input_sequence.data - self.pad_idx) == 0] = 1 decoder_input_sequence = input_sequence.clone() decoder_input_sequence[prob < self.word_dropout_rate] = self.unk_idx