Skip to content

Commit a9ff79d

Browse files
authored
Fix spellings
1 parent 3d2c2ba commit a9ff79d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

beginner_source/fgsm_tutorial.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,18 @@ def fgsm_attack(image, epsilon, data_grad):
233233
# Return the perturbed image
234234
return perturbed_image
235235

236-
# denormalize the tensors before performing an FGSM attack
237-
# because FGSM only works with the original unnormalized image
236+
# restores the tensors to their original scale
238237
def denorm(batch, mean=[0.1307], std=[0.3081]):
239238
"""
240-
Denormalizes a batch of tensors.
239+
Convert a batch of tensors to their original scale.
241240
242241
Args:
243242
batch (torch.Tensor): Batch of normalized tensors.
244243
mean (torch.Tensor or list): Mean used for normalization.
245244
std (torch.Tensor or list): Standard deviation used for normalization.
246245
247246
Returns:
248-
torch.Tensor: Denormalized batch of tensors.
247+
torch.Tensor: batch of tensors without normalization applied to them.
249248
"""
250249
if isinstance(mean, list):
251250
mean = torch.tensor(mean).to(device)
@@ -308,7 +307,7 @@ def test( model, device, test_loader, epsilon ):
308307
# Collect ``datagrad``
309308
data_grad = data.grad.data
310309

311-
# Denormalize the data
310+
# Restore the data to its original scale
312311
data_denorm = denorm(data)
313312

314313
# Call FGSM Attack

0 commit comments

Comments
 (0)