Shortcuts

torch.nn.utils.fuse_linear_bn_eval

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

将一个线性模块和一个批归一化模块融合成一个单一的新线性模块。

Parameters
  • 线性 (torch.nn.Linear) – 一个线性模块。

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

Returns

融合的线性模块。

Return type

torch.nn.Linear

注意

Both linear and bn 必须处于评估模式,并且 bn 必须计算其运行缓冲区。

优云智算