Skip to content

Commit

Permalink
aug name
Browse files Browse the repository at this point in the history
  • Loading branch information
astonzhang committed Dec 12, 2018
1 parent 7d224a8 commit 566fb99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chapter_computer-vision/image-augmentation.md
Expand Up @@ -114,11 +114,11 @@ show_images(gdata.vision.CIFAR10(train=True)[0:32][0], 4, 8, scale=0.8);
为了在预测时得到确定的结果,我们通常只将图像增广应用在训练样本上,而不在预测时使用含随机操作的图像增广。在这里我们仅仅使用最简单的随机左右翻转。此外,我们使用`ToTensor`实例将小批量图像转成MXNet需要的格式,即形状为(批量大小,通道数,高,宽)、值域在0到1之间且类型为32位浮点数。

```{.python .input n=33}
flip_lr_augs = gdata.vision.transforms.Compose([
flip_aug = gdata.vision.transforms.Compose([
gdata.vision.transforms.RandomFlipLeftRight(),
gdata.vision.transforms.ToTensor()])
no_augs = gdata.vision.transforms.Compose([
no_aug = gdata.vision.transforms.Compose([
gdata.vision.transforms.ToTensor()])
```

Expand Down Expand Up @@ -236,13 +236,13 @@ def train_with_data_aug(train_augs, test_augs, lr=0.001):
我们先观察使用了图像增广的结果。

```{.python .input n=39}
train_with_data_aug(flip_lr_augs, no_augs)
train_with_data_aug(flip_aug, no_aug)
```

作为对比,下面我们尝试不使用图像增广。

```{.python .input n=40}
train_with_data_aug(no_augs, no_augs)
train_with_data_aug(no_aug, no_aug)
```

可以看到,即使添加了简单的随机翻转也可能对训练产生一定的影响。图像增广通常会使训练准确率变低,但有可能提高测试准确率。它可以用来应对过拟合。
Expand Down

0 comments on commit 566fb99

Please sign in to comment.