torch.nn.utils.fuse_linear_bn_eval

torch.nn.utils.fuse_linear_bn_eval(linear, bn)[源代码]

将一个线性模块和一个批处理规范化模块融合成一个新的线性模块。

参数
  • linear (torch.nn.Linear) — 一个线性层。

  • bn (torch.nn.modules.batchnorm._BatchNorm) – 批归一化模块。

返回值

集成的线性模块。

返回类型

torch.nn.Linear

注意

Both linear and bn must be in eval mode, and bn needs to have its running buffers calculated.

本页目录