gpt4 book ai didi

python - pytorch卷积层中第一个初始化的权重是多少

转载 作者:行者123 更新时间:2023-12-01 01:19:25 27 4
gpt4 key购买 nike

我在Udacity PyTorch自学关于最后一段

Learning

In the code you've been working with, you've been setting the values of filter weights explicitly, but neural networks will actually learn the best filter weights as they train on a set of image data. You'll learn all about this type of neural network later in this section, but know that high-pass and low-pass filters are what define the behavior of a network like this, and you know how to code those from scratch!

In practice, you'll also find that many neural networks learn to detect the edges of images because the edges of object contain valuable information about the shape of an object.

我已经学习了最后 44 部分。但我无法回答以下问题

  1. 执行torch.nn.Conv2d时初始化的权重是多少?以及如何自己定义它?
  2. PyTorch 如何更新卷积层中的权重?

最佳答案

当您声明nn.Conv2d时,权重将通过此code初始化。

特别是,如果您给出偏差,它会使用 Kaiming 等人提出的初始化。它初始化为 (-bound,bound) 之间的均匀分布,其中 bound=\sqrt{6/((1+a^2)fan_in)} (请参阅 here )。

您也可以手动初始化权重。这已经在其他地方得到了回答(参见 here ),我不再重复。

当您调用optimizer.step并且优化器注册了卷积滤波器的参数时,它们会被更新。

关于python - pytorch卷积层中第一个初始化的权重是多少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53990652/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com