Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
a26546593
dive-into-dl-pytorch
提交
737d9c1a
D
dive-into-dl-pytorch
项目概览
a26546593
/
dive-into-dl-pytorch
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dive-into-dl-pytorch
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
737d9c1a
编写于
10月 24, 2019
作者:
S
ShusenTang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug #17: randn -> rand
上级
97df5349
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
18 deletion
+18
-18
code/chapter03_DL-basics/3.13_dropout.ipynb
code/chapter03_DL-basics/3.13_dropout.ipynb
+17
-17
docs/chapter03_DL-basics/3.13_dropout.md
docs/chapter03_DL-basics/3.13_dropout.md
+1
-1
未找到文件。
code/chapter03_DL-basics/3.13_dropout.ipynb
浏览文件 @
737d9c1a
...
...
@@ -9,7 +9,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"
0.4.1
\n"
"
1.2.0
\n"
]
}
],
...
...
@@ -40,7 +40,7 @@
" # 这种情况下把全部元素都丢弃\n",
" if keep_prob == 0:\n",
" return torch.zeros_like(X)\n",
" mask = (torch.rand
n
(X.shape) < keep_prob).float()\n",
" mask = (torch.rand(X.shape) < keep_prob).float()\n",
" \n",
" return mask * X / keep_prob"
]
...
...
@@ -54,7 +54,7 @@
"data": {
"text/plain": [
"tensor([[ 0., 1., 2., 3., 4., 5., 6., 7.],\n",
" [ 8., 9., 10., 11., 12.,
0
., 14., 15.]])"
" [ 8., 9., 10., 11., 12.,
13
., 14., 15.]])"
]
},
"execution_count": 3,
...
...
@@ -75,8 +75,8 @@
{
"data": {
"text/plain": [
"tensor([[ 0., 0., 4.,
0., 8
., 0., 12., 14.],\n",
" [ 0., 18., 20.,
0., 24., 0., 0., 3
0.]])"
"tensor([[ 0., 0., 4.,
6., 0
., 0., 12., 14.],\n",
" [ 0., 18., 20.,
22., 0., 0., 28.,
0.]])"
]
},
"execution_count": 4,
...
...
@@ -184,11 +184,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 1, loss 0.004
4, train acc 0.574, test acc 0.648
\n",
"epoch 2, loss 0.0023, train acc 0.78
6
, test acc 0.786\n",
"epoch 3, loss 0.0019, train acc 0.82
6, test acc 0.825
\n",
"epoch 4, loss 0.0017, train acc 0.83
9, test acc 0.831
\n",
"epoch 5, loss 0.0016, train acc 0.84
9, test acc 0.850
\n"
"epoch 1, loss 0.004
5, train acc 0.561, test acc 0.662
\n",
"epoch 2, loss 0.0023, train acc 0.78
3
, test acc 0.786\n",
"epoch 3, loss 0.0019, train acc 0.82
3, test acc 0.773
\n",
"epoch 4, loss 0.0017, train acc 0.83
8, test acc 0.847
\n",
"epoch 5, loss 0.0016, train acc 0.84
8, test acc 0.809
\n"
]
}
],
...
...
@@ -231,11 +231,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 1, loss 0.004
5, train acc 0.553, test acc 0.715
\n",
"epoch 2, loss 0.0023, train acc 0.7
84, test acc 0.793
\n",
"epoch 3, loss 0.00
19, train acc 0.822, test acc 0.817
\n",
"epoch 4, loss 0.0018, train acc 0.83
7, test acc 0.830
\n",
"epoch 5, loss 0.0016, train acc 0.848, test acc 0.8
39
\n"
"epoch 1, loss 0.004
8, train acc 0.526, test acc 0.743
\n",
"epoch 2, loss 0.0023, train acc 0.7
79, test acc 0.764
\n",
"epoch 3, loss 0.00
20, train acc 0.815, test acc 0.819
\n",
"epoch 4, loss 0.0018, train acc 0.83
6, test acc 0.814
\n",
"epoch 5, loss 0.0016, train acc 0.848, test acc 0.8
42
\n"
]
}
],
...
...
@@ -256,7 +256,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python
[default]
",
"display_name": "Python
3
",
"language": "python",
"name": "python3"
},
...
...
@@ -270,7 +270,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
2
"
}
},
"nbformat": 4,
...
...
docs/chapter03_DL-basics/3.13_dropout.md
浏览文件 @
737d9c1a
...
...
@@ -49,7 +49,7 @@ def dropout(X, drop_prob):
# 这种情况下把全部元素都丢弃
if
keep_prob
==
0
:
return
torch
.
zeros_like
(
X
)
mask
=
(
torch
.
rand
n
(
X
.
shape
)
<
keep_prob
).
float
()
mask
=
(
torch
.
rand
(
X
.
shape
)
<
keep_prob
).
float
()
return
mask
*
X
/
keep_prob
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录