torch.nn.utils.fusion.fuse_linear_bn_weights#
- torch.nn.utils.fusion.fuse_linear_bn_weights(linear_w, linear_b, bn_rm, bn_rv, bn_eps, bn_w, bn_b)[原始碼]#
將線性模組引數和 BatchNorm 模組引數融合為新的線性模組引數。
- 引數
linear_w (torch.Tensor) – 線性層的權重。
linear_b (Optional[torch.Tensor]) – 線性層的偏置。
bn_rm (torch.Tensor) – BatchNorm 執行均值。
bn_rv (torch.Tensor) – BatchNorm 執行方差。
bn_eps (float) – BatchNorm epsilon。
bn_w (torch.Tensor) – BatchNorm 層的權重。
bn_b (torch.Tensor) – BatchNorm 層的偏置。
- 返回
融合後的線性層權重和偏置。
- 返回型別
Tuple[torch.nn.Parameter, torch.nn.Parameter]