kornia / tutorials

Repository containing the Kornia related tutorials
https://kornia.github.io/tutorials/
Apache License 2.0
45 stars 32 forks source link

Example notebook bug? #86

Closed kvenkman closed 9 months ago

kvenkman commented 9 months ago

I was looking at the data augmentation example notebook, and was hoping to clarify a potential bug. In the training_step method:

    def training_step(self, batch, batch_idx):
        # REQUIRED
        x, y = batch
        x_aug = self.transform(x)  # => we perform GPU/Batched data augmentation
        logits = self.forward(x_aug)
        loss = F.cross_entropy(logits, y)
        self.log("train_acc_step", self.accuracy(logits.argmax(1), y))
        self.log("train_loss", loss)
        return loss

the input tensor x gets transformed to x_aug, yet the corresponding transform does not get applied to the labels y before loss is calculated (loss = F.cross_entropy(logits, y)). Is this an error that needs fixing, or am I missing something?

edgarriba commented 9 months ago

In this example we follow a standard augmentation strategy applying perturbations only in the input image. Labels are image unique ids, which do not get modified by color jitter augmentation

kvenkman commented 9 months ago

Oh, so the labels are one hot encoded vectors?

edgarriba commented 9 months ago

If you notice, the dataset is CIFAR10

kvenkman commented 9 months ago

I see that now - thank you for the clarification!