From cb0b6a5ba8d6b000d4844d0e8ab74c865744429d Mon Sep 17 00:00:00 2001 From: directdoge <79967984+dir-44@users.noreply.github.com> Date: Mon, 20 Jan 2025 10:25:37 +0800 Subject: [PATCH] Update adv_image.py add English comments --- deepsecure/adv_image.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deepsecure/adv_image.py b/deepsecure/adv_image.py index 31b8b1d..bf62e37 100644 --- a/deepsecure/adv_image.py +++ b/deepsecure/adv_image.py @@ -70,12 +70,21 @@ def train(self, train_dataloader, epochs): lr=0.00001) loss_adv_sum = 0 self.ite = epoch + + # Iterate over the training data loader for i, data in enumerate(train_dataloader, start=0): + # Unpack the current batch of images and labels images, labels = data + + # Move the images and labels to the specified device (e.g., GPU or CPU) images, labels = images.to(self.device), labels.to(self.device) - + + # Perform training for the current batch and obtain adversarial loss and adversarial images loss_adv_batch, adv_img = self.train_batch(images) + + # Accumulate the adversarial loss over all batches loss_adv_sum += loss_adv_batch + # print statistics