做数据扩充的时候要不要训练原始数据点?
Should we train the original data point when we do data augmentation?
我对数据增强的定义感到困惑。我们应该训练原始数据点和转换后的数据点还是只训练转换后的数据点?如果我们同时训练两者,那么我们将增加数据集的大小,而第二种方法则不会。
我在使用函数 RandomResizedCrop 时遇到了这个问题。
'train': transforms.Compose([
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
]),
如果我们随机调整和裁剪一些数据集,我们实际上并没有增加数据集的大小来进行数据扩充。那是对的吗?或者数据扩充只需要 change/modification 原始数据集而不是增加它的大小?
谢谢。
transform.compose 就像预处理图像一样,将一种形式转换为特定的适合形式
在单个图像上应用变换意味着改变它的像素值并且它不会增加数据集大小
要获取更多数据集,您必须执行如下操作:
final_train_data = []
final_target_train = []
for i in tqdm(range(train_x.shape[0])):
final_train_data.append(train_x[i])
final_train_data.append(rotate(train_x[i], angle=45, mode = 'wrap'))
final_train_data.append(np.fliplr(train_x[i]))
final_train_data.append(np.flipud(train_x[i]))
final_train_data.append(random_noise(train_x[i],var=0.2**2))
for j in range(5):
final_target_train.append(train_y[i])
了解更多详情pytorch
根据定义,或至少 influential paper AlexNet from 2012 that popularized data augmentation in computer vision, increases the size of the training set. Hence the word augmentation. Go ahead and have a look at Section 4.1 from the AlexNet paper。但是,这是我从论文中引用的要点:
The easiest and most common method to reduce overfitting on image data is to artificially enlarge the dataset using label-preserving transformations. The first form of data augmentation consists of generating image translations and horizontal reflections. We do this by extracting random 224 × 224 patches (and their horizontal reflections) from the 256×256 images and training our network on these extracted patches. This increases the size of our training set by a factor of 2048, though the resulting training examples are, of course, highly interdependent.
至于具体实现,这取决于您的用例,最重要的是您的训练数据的大小。如果您在后一种情况下数量不足,您应该考虑对原始图像和转换后的图像进行训练,充分注意保留标签。
我对数据增强的定义感到困惑。我们应该训练原始数据点和转换后的数据点还是只训练转换后的数据点?如果我们同时训练两者,那么我们将增加数据集的大小,而第二种方法则不会。
我在使用函数 RandomResizedCrop 时遇到了这个问题。
'train': transforms.Compose([
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
]),
如果我们随机调整和裁剪一些数据集,我们实际上并没有增加数据集的大小来进行数据扩充。那是对的吗?或者数据扩充只需要 change/modification 原始数据集而不是增加它的大小?
谢谢。
transform.compose 就像预处理图像一样,将一种形式转换为特定的适合形式
在单个图像上应用变换意味着改变它的像素值并且它不会增加数据集大小
要获取更多数据集,您必须执行如下操作:
final_train_data = []
final_target_train = []
for i in tqdm(range(train_x.shape[0])):
final_train_data.append(train_x[i])
final_train_data.append(rotate(train_x[i], angle=45, mode = 'wrap'))
final_train_data.append(np.fliplr(train_x[i]))
final_train_data.append(np.flipud(train_x[i]))
final_train_data.append(random_noise(train_x[i],var=0.2**2))
for j in range(5):
final_target_train.append(train_y[i])
了解更多详情pytorch
根据定义,或至少 influential paper AlexNet from 2012 that popularized data augmentation in computer vision, increases the size of the training set. Hence the word augmentation. Go ahead and have a look at Section 4.1 from the AlexNet paper。但是,这是我从论文中引用的要点:
The easiest and most common method to reduce overfitting on image data is to artificially enlarge the dataset using label-preserving transformations. The first form of data augmentation consists of generating image translations and horizontal reflections. We do this by extracting random 224 × 224 patches (and their horizontal reflections) from the 256×256 images and training our network on these extracted patches. This increases the size of our training set by a factor of 2048, though the resulting training examples are, of course, highly interdependent.
至于具体实现,这取决于您的用例,最重要的是您的训练数据的大小。如果您在后一种情况下数量不足,您应该考虑对原始图像和转换后的图像进行训练,充分注意保留标签。