Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
d2l-zh
提交
699b1b19
D
d2l-zh
项目概览
OpenDocCN
/
d2l-zh
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
d2l-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
699b1b19
编写于
7月 11, 2018
作者:
A
Aston Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
img aug
上级
4aecbe43
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
7 deletion
+7
-7
chapter_appendix/gluonbook.md
chapter_appendix/gluonbook.md
+1
-1
chapter_computer-vision/image-augmentation.md
chapter_computer-vision/image-augmentation.md
+4
-4
gluonbook/utils.py
gluonbook/utils.py
+2
-2
未找到文件。
chapter_appendix/gluonbook.md
浏览文件 @
699b1b19
...
...
@@ -14,7 +14,7 @@
*
`data_iter_random`
,
[
循环神经网络
](
../chapter_recurrent-neural-networks/rnn.md
)
*
`evaluate_accuracy`
,
[
Softmax回归的从零开始实现
](
../chapter_deep-learning-basics/softmax-regression-scratch.md
)
*
`evaluate_accuracy`
,
*
`grad_clipping`
,
[
循环神经网络
](
../chapter_recurrent-neural-networks/rnn.md
)
...
...
chapter_computer-vision/image-augmentation.md
浏览文件 @
699b1b19
...
...
@@ -114,10 +114,10 @@ def load_cifar10(is_train, augs, batch_size):
### 模型训练
我们使用ResNet
18来训练CIFAR-10。训练的
的代码与
[
“残差网络:ResNet”
](
../chapter_convolutional-neural-networks/resnet.md
)
中一致,除了使用所有可用的GPU和不同的学习率外。
我们使用ResNet
-18来训练CIFAR-10。训练
的代码与
[
“残差网络:ResNet”
](
../chapter_convolutional-neural-networks/resnet.md
)
中一致,除了使用所有可用的GPU和不同的学习率外。
```
{.python .input n=13}
def train(train_augs, test_augs, lr=0.1):
def train
_with_data_aug
(train_augs, test_augs, lr=0.1):
batch_size = 256
ctx = gb.try_all_gpus()
net = gb.resnet18(10)
...
...
@@ -132,13 +132,13 @@ def train(train_augs, test_augs, lr=0.1):
首先我们看使用了图片增广的情况。
```
{.python .input n=14}
train(train_augs, test_augs)
train
_with_data_aug
(train_augs, test_augs)
```
作为对比,我们尝试只对训练数据做中间剪裁。
```
{.python .input n=15}
train(test_augs, test_augs)
train
_with_data_aug
(test_augs, test_augs)
```
可以看到,即使是简单的随机翻转也会有明显的效果。图片增广类似于正则项,它使得训练精度变低,但可以提高测试精度。
...
...
gluonbook/utils.py
浏览文件 @
699b1b19
...
...
@@ -399,7 +399,7 @@ def train(train_iter, test_iter, net, loss, trainer, ctx, num_epochs,
trainer
.
step
(
batch_size
)
n
+=
batch_size
m
+=
sum
([
y
.
size
for
y
in
ys
])
if
print_batches
and
(
i
+
1
)
%
print_batches
==
0
:
if
print_batches
and
(
i
+
1
)
%
print_batches
==
0
:
print
(
'batch %d, loss %f, train acc %f'
%
(
n
,
train_l_sum
/
n
,
train_acc_sum
/
m
))
...
...
@@ -488,7 +488,7 @@ def train_ch3(net, train_iter, test_iter, loss, num_epochs, batch_size,
def
try_all_gpus
():
"""Return all available GPUs, or [mx.
g
pu()] if there is no GPU."""
"""Return all available GPUs, or [mx.
c
pu()] if there is no GPU."""
ctxes
=
[]
try
:
for
i
in
range
(
16
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录