Skip to content

Commit 2fe796b

Browse files
committed
rearrange code for cuda()
1 parent 5061df5 commit 2fe796b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tutorials/09 - Image Captioning/train.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ def main():
5555
# Set mini-batch dataset
5656
images = Variable(images)
5757
captions = Variable(captions)
58-
targets = pack_padded_sequence(captions, lengths, batch_first=True)[0]
59-
6058
if torch.cuda.is_available():
6159
images = images.cuda()
6260
captions = captions.cuda()
63-
61+
targets = pack_padded_sequence(captions, lengths, batch_first=True)[0]
62+
6463
# Forward, Backward and Optimize
6564
decoder.zero_grad()
6665
encoder.zero_grad()

0 commit comments

Comments
 (0)