Augmenting (only Trainset, not Testset) Before Training: RuntimeError: inconsistent tensor sizes

ERROR PyTorch 0.1.11

it is likely because the images in your train_dataset are of different sizes, and loader is trying to concatenate them before returning them to you (by default that’s what loader will do).

You can do two things:

  1. add a transform to dataset that crops the outputs to a fixed value
  2. give your own collate_fn function to loader that concatenates the dataset outputs of a mini-batch in a different way than the default one
2 Likes

Hmm so by different sizes, you mean file size, not image resolution, right?
Because all of the images in the folder it is drawing from before augmenting are 256x256.

i mean image resolution.

You can check what is the incorrect size by printing the sizes of tensors in a custom collate_fn that you supply.

3 Likes

Ah, I understand now, you’re right, the particular augmentation I am doing is scaling the images such that they are no longer 256x256.

Thanks

It is great that you have included this flexibility in the library.