Skip to content

Commit 4673b14

Browse files
authored
Add model.eval() in neural_style_tutorial.py (#2371)
1 parent 7aff96c commit 4673b14

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: advanced_source/neural_style_tutorial.py

+3
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ def run_style_transfer(cnn, normalization_mean, normalization_std,
423423
# We want to optimize the input and not the model parameters so we
424424
# update all the requires_grad fields accordingly
425425
input_img.requires_grad_(True)
426+
# We also put the model in evaluation mode, so that specific layers
427+
# such as dropout or batch normalization layers behave correctly.
428+
model.eval()
426429
model.requires_grad_(False)
427430

428431
optimizer = get_input_optimizer(input_img)

0 commit comments

Comments
 (0)