Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
d2l-zh
提交
7d4e4404
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 搜索 >>
提交
7d4e4404
编写于
4月 04, 2018
作者:
A
Aston Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reshape(())
上级
2aab0f6a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
8 addition
and
8 deletion
+8
-8
chapter_optimization/adadelta-scratch.md
chapter_optimization/adadelta-scratch.md
+1
-1
chapter_optimization/adagrad-scratch.md
chapter_optimization/adagrad-scratch.md
+1
-1
chapter_optimization/adam-scratch.md
chapter_optimization/adam-scratch.md
+1
-1
chapter_optimization/gd-sgd-scratch.md
chapter_optimization/gd-sgd-scratch.md
+1
-1
chapter_optimization/momentum-scratch.md
chapter_optimization/momentum-scratch.md
+1
-1
chapter_optimization/rmsprop-scratch.md
chapter_optimization/rmsprop-scratch.md
+1
-1
utils.py
utils.py
+2
-2
未找到文件。
chapter_optimization/adadelta-scratch.md
浏览文件 @
7d4e4404
...
...
@@ -109,7 +109,7 @@ def optimize(batch_size, rho, num_epochs, log_interval):
y_vals.append(squared_loss(net(X, w, b), y).mean().asnumpy())
print('epoch %d, loss %.4e' % (epoch, y_vals[-1]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print('w:', w.reshape(
1, -1
).asnumpy(), 'b:', b.asscalar(), '\n')
print('w:', w.reshape(
(1, -1)
).asnumpy(), 'b:', b.asscalar(), '\n')
x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
utils.set_fig_size(mpl)
plt.semilogy(x_vals, y_vals)
...
...
chapter_optimization/adagrad-scratch.md
浏览文件 @
7d4e4404
...
...
@@ -126,7 +126,7 @@ def optimize(batch_size, lr, num_epochs, log_interval):
print('epoch %d, learning rate %f, loss %.4e' % (epoch, lr,
y_vals[-1]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print('w:', w.reshape(
1, -1
).asnumpy(), 'b:', b.asscalar(), '\n')
print('w:', w.reshape(
(1, -1)
).asnumpy(), 'b:', b.asscalar(), '\n')
x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
utils.set_fig_size(mpl)
plt.semilogy(x_vals, y_vals)
...
...
chapter_optimization/adam-scratch.md
浏览文件 @
7d4e4404
...
...
@@ -146,7 +146,7 @@ def optimize(batch_size, lr, num_epochs, log_interval):
print('epoch %d, learning rate %f, loss %.4e' % (epoch, lr,
y_vals[-1]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print('w:', w.reshape(
1, -1
).asnumpy(), 'b:', b.asscalar(), '\n')
print('w:', w.reshape(
(1, -1)
).asnumpy(), 'b:', b.asscalar(), '\n')
x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
utils.set_fig_size(mpl)
plt.semilogy(x_vals, y_vals)
...
...
chapter_optimization/gd-sgd-scratch.md
浏览文件 @
7d4e4404
...
...
@@ -194,7 +194,7 @@ def optimize(batch_size, lr, num_epochs, log_interval, decay_epoch):
print('epoch %d, learning rate %f, loss %.4e' % (epoch, lr,
y_vals[-1]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print('w:', w.reshape(
1, -1
).asnumpy(), 'b:', b.asscalar(), '\n')
print('w:', w.reshape(
(1, -1)
).asnumpy(), 'b:', b.asscalar(), '\n')
x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
utils.set_fig_size(mpl)
plt.semilogy(x_vals, y_vals)
...
...
chapter_optimization/momentum-scratch.md
浏览文件 @
7d4e4404
...
...
@@ -122,7 +122,7 @@ def optimize(batch_size, lr, mom, num_epochs, log_interval):
print('epoch %d, learning rate %f, loss %.4e' % (epoch, lr,
y_vals[-1]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print('w:', w.reshape(
1, -1
).asnumpy(), 'b:', b.asscalar(), '\n')
print('w:', w.reshape(
(1, -1)
).asnumpy(), 'b:', b.asscalar(), '\n')
x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
utils.set_fig_size(mpl)
plt.semilogy(x_vals, y_vals)
...
...
chapter_optimization/rmsprop-scratch.md
浏览文件 @
7d4e4404
...
...
@@ -108,7 +108,7 @@ def optimize(batch_size, lr, gamma, num_epochs, log_interval):
print('epoch %d, learning rate %f, loss %.4e' % (epoch, lr,
y_vals[-1]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print('w:', w.reshape(
1, -1
).asnumpy(), 'b:', b.asscalar(), '\n')
print('w:', w.reshape(
(1, -1)
).asnumpy(), 'b:', b.asscalar(), '\n')
x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
utils.set_fig_size(mpl)
plt.semilogy(x_vals, y_vals)
...
...
utils.py
浏览文件 @
7d4e4404
...
...
@@ -401,8 +401,8 @@ def optimize(batch_size, trainer, num_epochs, decay_epoch, log_interval, X, y,
else
:
print
(
"epoch %d, loss %.4e"
%
(
epoch
,
y_vals
[
-
1
]))
# 为了便于打印,改变输出形状并转化成numpy数组。
print
(
'w:'
,
n
p
.
reshape
(
net
[
0
].
weight
.
data
().
asnumpy
(),
(
1
,
-
1
)
),
'b:'
,
net
[
0
].
bias
.
data
().
as
numpy
()[
0
]
,
'
\n
'
)
print
(
'w:'
,
n
et
[
0
].
weight
.
data
().
reshape
((
1
,
-
1
)).
asnumpy
(
),
'b:'
,
net
[
0
].
bias
.
data
().
as
scalar
()
,
'
\n
'
)
x_vals
=
np
.
linspace
(
0
,
num_epochs
,
len
(
y_vals
),
endpoint
=
True
)
set_fig_size
(
mpl
)
plt
.
semilogy
(
x_vals
,
y_vals
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录