You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5 lines
677 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 4.3 模型参数的延后初始化
由于使用Gluon创建的全连接层的时候不需要指定输入个数。所以当调用`initialize`函数时,由于隐藏层输入个数依然未知,系统也无法得知该层权重参数的形状。只有在当形状已知的输入`X`传进网络做前向计算`net(X)`时系统才推断出该层的权重参数形状为多少此时才进行真正的初始化操作。但是使用PyTorch在定义模型的时候就要指定输入的形状所以也就不存在这个问题了所以本节略。有兴趣的可以去看看原文[传送门](https://zh.d2l.ai/chapter_deep-learning-computation/deferred-init.html)。