Skip to content

Commit dc5a186

Browse files
authored
Merge branch 'main' into add-matplotlib
2 parents b34f12b + 4673b14 commit dc5a186

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

advanced_source/neural_style_tutorial.py

Lines changed: 3 additions & 0 deletions
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)

beginner_source/nn_tutorial.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
import numpy as np
7676

7777
pyplot.imshow(x_train[0].reshape((28, 28)), cmap="gray")
78+
# ``pyplot.show()`` only if not on Colab
79+
try:
80+
import google.colab
81+
except ImportError:
82+
pyplot.show()
7883
print(x_train.shape)
7984

8085
###############################################################################

0 commit comments

Comments
 (0)