forked from ShusenTang/Dive-into-DL-PyTorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b85dc22
commit 878782d
Showing
1 changed file
with
4 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 4.3 模型参数的延后初始化 | ||
|
||
由于使用Gluon创建的全连接层的时候不需要指定输入个数。所以当调用`initialize`函数时,由于隐藏层输入个数依然未知,系统也无法得知该层权重参数的形状。只有在当形状已知的输入`X`传进网络做前向计算`net(X)`时,系统才推断出该层的权重参数形状为多少,此时才进行真正的初始化操作。但是使用PyTorch在定义模型的时候就要指定输入的形状,所以也就不存在这个问题了,所以本节略。有兴趣的可以去看看原文,[传送门](https://zh.d2l.ai/chapter_deep-learning-computation/deferred-init.html)。 | ||
|