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模块参数融合为新的线性模块参数。
- Parameters
linear_w (torch.Tensor) – 线性权重。
linear_b (可选[torch.Tensor]) – 线性偏置。
bn_rm (torch.Tensor) – 批归一化运行均值。
bn_rv (torch.Tensor) – 批归一化运行方差。
bn_eps (float) – 批归一化epsilon。
bn_w (torch.Tensor) – 批归一化权重。
bn_b (torch.Tensor) – 批归一化偏置。
转置 (bool, 可选) – 如果为 True,则转置卷积权重。默认为 False。
- Returns
融合的线性权重和偏置。
- Return type
元组[torch.nn.Parameter, torch.nn.Parameter]