File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 154154# VGG). For this, we have ``torch.cuda.is_available()`` that returns
155155# ``True`` if you computer has an available GPU. Then, we can set the
156156# ``torch.device`` that will be used in this script. Then, we will use
157- # the method ``.to(device)`` that a tensor or a module to the desired
157+ # the method ``.to(device)`` that moves a tensor or a module to the desired
158158# device. When we want to move back this tensor or module to the
159159# CPU (e.g. to use numpy), we can use the ``.cpu()`` method.
160160
@@ -561,7 +561,11 @@ def closure():
561561 for cl in content_losses :
562562 content_score += cl .loss
563563
564- (style_score * style_weight + content_score * content_weight ).backward ()
564+ style_score *= style_weight
565+ content_score *= content_weight
566+
567+ loss = style_score + content_score
568+ loss .backward ()
565569
566570 run [0 ] += 1
567571 if run [0 ] % 50 == 0 :
You can’t perform that action at this time.
0 commit comments