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)[source][source]¶
将线性模块参数和 BatchNorm 模块参数融合成新的线性模块参数。
- 参数:
线性_w (torch.Tensor) – 线性权重。
linear_b (Optional[torch.Tensor]) – 线性偏置。
bn_rm (torch.Tensor) – BatchNorm 运行均值。
bn_rv (torch.Tensor) – BatchNorm 运行方差。
bn_eps (浮点数) – 批标准化 epsilon。
bn_w (torch.Tensor) – 批标准化权重。
bn_b (torch.Tensor) – 批标准化偏差。
- 返回值:
混合线性权重和偏差。
- 返回类型:
torch.nn.Parameter 元组