pytorch kaiming
时间: 2023-06-23 10:57:56 浏览: 148
对Pytorch神经网络初始化kaiming分布详解
5星 · 资源好评率100%
Kaiming Initialization is a weight initialization method for neural networks, named after Kaiming He, who proposed it in his 2015 paper "Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification". It is a modification of the Xavier Initialization method that is better suited for deep neural networks.
In PyTorch, Kaiming Initialization can be applied to a layer's weights using the `kaiming_uniform_` or `kaiming_normal_` functions, depending on whether you want to use a uniform or normal distribution for the initialization. For example, to initialize the weights of a linear layer with Kaiming Initialization using a normal distribution, you can do:
```
import torch.nn as nn
linear_layer = nn.Linear(in_features=10, out_features=20)
nn.init.kaiming_normal_(linear_layer.weight)
```
This will initialize the weights of the `linear_layer` using Kaiming Initialization with a normal distribution.
阅读全文