torch.nn.utils.fuse_linear_bn_weights¶
- torch.nn.utils.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]