深度学习 之 data augmentation

深度学习是基于数据驱动的学科,通过data augmentation(数据扩张)可以有效的进行数据扩张并进行一些数据normalized操作. 以此,便于扩大数据集,丰富数据多样性,便于学习到更深度广泛的特征, 避免模型的overfit和underfit.
这里直接调用keras.preprocessing.image中的ImageDataGenerator. 这个函数包含了常用的图像变换和normalization方法.

  • 函数介绍
from keras.preprocessing.image import ImageDataGenerator

? ImageDataGenerator # 查看函数帮助
  • 函数参数列表(带默认值)如下:
    1. featurewise_center=False:
      设置输入特征的均值为0(每一个维度,feature-wise)
      Set input mean to 0 over the dataset, feature-wise.
    2. samplewise_center=False:
      设置每一个样本的均值为0.(样本级别的均值, 也就是该样本所有特征之和的平均为0)
      Set each sample mean to 0.
    3. featurewise_std_normalization=False
      每一个特征维度除以该维度的标准差.
      Divide inputs by std of the dataset, feature-wise.
    4. samplewise_std_normalization=False
      每一个特征(所有维度)整体除以相应的标准差.
      Divide each input by its std.
    5. zca_whitening=False
      采用ZCA白化操作.
      Apply ZCA(Zero-phase Component Analysis) whitening
    6. zca_epsilon=1e-06
      epsilon值
      epsilon for ZCA whitening. Default is 1e-6.
    7. rotation_range=0.0
      随机旋转的最大值.?
      Degree range for random rotations.
    8. width_shift_range=0.0
      水平平移的比例范围(范围的最大值)
      Float (fraction of total width). Range for random horizontal shifts.
    9. height_shift_range=0.0
      纵向平移的比例返回(范围的最大值)
      Float (fraction of total height). Range for random vertical shifts.
    10. brightness_range=None
    11. shear_range=0.0
      裁剪强度范围最大值(逆时针方向角度)
      Shear Intensity (Shear angle in counter-clockwise direction in degrees)
    12. zoom_range=0.0
      随机缩放范围(到底zoom in/out)
      Float or [lower, upper]. Range for random zoom. If a float, [lower, upper] = [1-zoom_range, 1+zoom_range].
    13. channel_shift_range=0.0
      Range for random channel shifts.
    14. fill_mode=’nearest’
      One of {“constant”, “nearest”, “reflect” or “wrap”}. Default is ‘nearest’.
      Points outside the boundaries of the input are filled according to the given mode:
      ‘constant’: kkkkkkkk|abcd|kkkkkkkk (cval=k)
      ‘nearest’: aaaaaaaa|abcd|dddddddd
      ‘reflect’: abcddcba|abcd|dcbaabcd
      ‘wrap’: abcdabcd|abcd|abcdabcd
    15. cval=0.0
      Value used for points outside the boundaries when fill_mode = "constant".
    16. horizontal_flip=False
      Randomly flip inputs horizontally. (难道不是=True, 就一定翻转?), 如果是随机翻转, 则说明,选择该项之后, 在训练过程中随机对图片执行该操作, 而不是一定执行. 如果一定执行,那么训练集的数量就会增加., 应该是随机翻转.
    17. vertical_flip=False
      Randomly flip inputs vertically.
    18. rescale=None
      Defaults to None. If None or 0, no rescaling is applied,otherwise we multiply the data by the value provided (before applying any other transformation).
    19. preprocessing_function=None
      function that will be implied on each input. The function will run after the image is resized and augmented. The function should take one argument: one image (Numpy tensor with rank 3), and should output a Numpy tensor with the same shape.
    20. data_format=None
      One of {“channels_first”, “channels_last”}.
      “channels_last” mode means that the images should have shape (samples, height, width, channels),
      “channels_first” mode means that the images should have shape (samples, channels, height, width).
      It defaults to the image_data_format value found in your
      Keras config file at ~/.keras/keras.json.
      If you never set it, then it will be “channels_last”.
    21. validation_split=0.0
      Fraction of images reserved for validation (strictly between 0 and 1)

深度学习

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
哈工大最新《自然语言处理数据增强方法》综述论文,155页pdf阐述复述、噪声和抽样三大数据增强方法 数据增强(DA)是一种有效的策略,可以缓解深度学习技术可能失败的数据稀缺情况。它在计算机视觉中得到了广泛的应用,然后被引入到自然语言处理中,并在许多任务中取得了改进。DA方法的重点之一是提高训练数据的多样性,从而帮助模型更好地泛化到未见测试数据。在本研究中,我们根据扩充数据的多样性,将数据增强方法分为三大类,即复述、噪声和抽样。本文从以上几个方面对数据挖掘方法进行了详细的分析。此外,我们还介绍了它们在自然语言处理任务中的应用以及面临的挑战。 引言 数据增强(Data Augmentation,简称DA),是指根据现有数据,合成新数据的一类方法。毕竟数据才是真正的效果天花板,有了更多数据后可以提升效果、增强模型泛化能力、提高鲁棒性等。然而由于NLP任务天生的难度,类似CV的裁剪方法可能会改变语义,既要保证数据质量又要保证多样性,使得大家在做数据增强时十分谨慎。 作者根据生成样本的多样性程度,将DA方法分为了以下三种: Paraphrasing:对句子中的词、短语、句子结构做一些更改,保留原始的语义 Noising:在保证label不变的同时,增加一些离散或连续的噪声,对语义的影响不大 Sampling:旨在根据目前的数据分布选取新的样本,会生成更多样的数据

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值