Paddle中paddle.fluid.layers.batch_norm和Pytorch中nn.BatchNorm1d是否对齐?
Created by: aprilvkuo
只进行infer不训练, 前向传播效果有diff
# 保留了pytorch中的bn参数
self.bn = nn.BatchNorm1d(hidden_size*2)
bn_weight = self.bn.weight.detach().numpy()
bn_bias = self.bn.bias.detach().numpy()
省略了numpy保存和加载过程
# paddle中加载bn参数
out = fluid.layers.batch_norm(out, param_attr=para_dict["bn_weight"],bias_attr=para_dict["bn_bias"], is_test=True, do_model_average_for_mean_and_var=True)