FP16 训练 ResNet50 添加 label_smooth 报错
Created by: mzchtx
环境
- system: centos6u3
- python: 2.7.14
- paddle: 1.5.1.post97
- nccl: 2.2.13
问题
使用 FP16 训练 ResNet50,如果添加 label_smooth
则会报错,代码如下:
out = ResNet50().net(input=image, class_dim=class_dim)
epsilon = 0.1
one_hot_label = fluid.layers.one_hot(input=label, depth=class_dim)
smooth_label = fluid.layers.label_smooth(label=one_hot_label, epsilon=epsilon)
cost = fluid.layers.softmax_with_cross_entropy(out, smooth_label, soft_label=True)
avg_cost = fluid.layers.mean(x=cost)
错误信息:
去掉 label_smooth
正常:
out = ResNet50().net(input=image, class_dim=class_dim)
cost = fluid.layers.softmax_with_cross_entropy(out, label, soft_label=True)
avg_cost = fluid.layers.mean(x=cost)