title: Correct data loading, splitting and augmentation in Pytorch
body: <p>The tutorial doesn't seem to explain how we should load, split and do proper augmentation.</p>
  
  <p>Let's have a dataset consisting of cars and cats. The folder structure would be:</p>
  
  <pre><code>data
    cat
      0101.jpg
      0201.jpg
      ...
    dogs
      0101.jpg
      0201.jpg
      ...
  </code></pre>
  
  <p>At first, I loaded the dataset by datasets.ImageFolder function. Image Function has command "TRANSFORM" where we can set some augmentation commands, but we don't want to apply augmentation to test dataset! So let's stay with transform=None. </p>
  
  <pre><code>data = datasets.ImageFolder(root='data')
  </code></pre>
  
  <p>Apparently, we don't have folder structure train and test and therefore I assume a good approach would be to use <a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.random_split" rel="nofollow noreferrer">split_dataset function</a> </p>
  
  <pre><code>    train_size = int(split * len(data))
      test_size = len(data) - train_size
      train_dataset, test_dataset = torch.utils.data.random_split(data, [train_size, test_size])
  </code></pre>
  
  <p>Now let's load the data the following way. </p>
  
  <pre><code>    train_loader = torch.utils.data.DataLoader(train_dataset,
                                                batch_size=8,
                                                shuffle=True)
      test_loader = torch.utils.data.DataLoader(test_dataset,
                                                batch_size=8,
                                                shuffle=True)
  </code></pre>
  
  <p>How can I apply transformations (data augmentation) to the "train_loader" images? </p>
  
  <p>Basically I need to: 1. load data from the folder structure explained above
  2. split the data into test/train parts
  3. apply augmentations on train part.  </p>