Skip to content

Commit 3d2c2ba

Browse files
authored
load state_dict on device instead of cpu
1 parent 538fe9f commit 3d2c2ba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

beginner_source/fgsm_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def forward(self, x):
198198
model = Net().to(device)
199199

200200
# Load the pretrained model
201-
model.load_state_dict(torch.load(pretrained_model, map_location='cpu'))
201+
model.load_state_dict(torch.load(pretrained_model, map_location=device))
202202

203203
# Set the model in evaluation mode. In this case this is for the Dropout layers
204204
model.eval()

0 commit comments

Comments
 (0)