how to apply data augmentation?
jingyao16 opened this issue · 5 comments
how to apply data augmentation?
Thanks for your reply. Yes, I have seen those options and flags in class HyperX. What awkward is, I am a cookie, don't know how to activate getitem function in a instance object as train_dataset. Could you please kindly show how to get an augmented dataset before sending into dataloader
@YunyanYao Data augmentation is done on-the-fly when training, I am not sure that I understand correctly what you wish to achieve.
@nshaud First, thanks for your code, I and my colleague shall cite your github link in our submitted paper.
Then, let me detail my situation. Previously, we use the MatConvNet to build our deep model, we manually augment training data, apply five transformations to each sample, after which we get a new training dataset with a six times bigger size.
I am wondering how can I modify your code to achieve the same purpose. Specifically, after wrap 'train_dataset' by 'DataLoader', and get a new 'train_loader' with bigger size.
I am wondering how can I modify your code to achieve the same purpose. Specifically, after wrap 'train_dataset' by 'DataLoader', and get a new 'train_loader' with bigger size.
So you actually want to perform an offline data augmentation. This is not the typical usecase for our code but you can just cherry-pick the functions that you need.
For example (not actual code but it should give you the idea):
from datasets import HyperX
my_dataset = HyperX(my_data, my_gt, radiation_augmentation=True, mixture_augmentation=True, ...)
n_samples = len(my_dataset)
augmented_dataset = []
for _ in range(6 * n_samples):
augmented_dataset.append(my_dataset[i % n_samples].numpy())
# augmented_dataset now has 6 times more samples than the original dataset after data augmentation
...