From efde56ffc6656b627685a629c1b5332fdd8a37a7 Mon Sep 17 00:00:00 2001 From: gaotingquan Date: Sun, 10 Apr 2022 13:38:16 +0000 Subject: [PATCH] fix: only fp16 evaluation is supported when ampO2 is enabled --- ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2_ultra.yaml | 2 ++ .../ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml | 2 ++ ppcls/engine/evaluation/classification.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2_ultra.yaml b/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2_ultra.yaml index 6a4425b4..db718840 100644 --- a/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2_ultra.yaml +++ b/ppcls/configs/ImageNet/ResNet/ResNet50_amp_O2_ultra.yaml @@ -24,6 +24,8 @@ AMP: use_dynamic_loss_scaling: True # O2: pure fp16 level: O2 + # only FP16 evaluation is supported when AMP O2 is enabled + use_fp16_test: True # model architecture Arch: diff --git a/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml b/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml index da005d32..349de441 100644 --- a/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml +++ b/ppcls/configs/ImageNet/SENet/SE_ResNeXt101_32x4d_amp_O2_ultra.yaml @@ -38,6 +38,8 @@ AMP: use_dynamic_loss_scaling: True # O2: pure fp16 level: O2 + # only FP16 evaluation is supported when AMP O2 is enabled + use_fp16_test: True Optimizer: name: Momentum diff --git a/ppcls/engine/evaluation/classification.py b/ppcls/engine/evaluation/classification.py index e9836fcb..3be00d52 100644 --- a/ppcls/engine/evaluation/classification.py +++ b/ppcls/engine/evaluation/classification.py @@ -53,7 +53,7 @@ def classification_eval(engine, epoch_id=0): ] time_info["reader_cost"].update(time.time() - tic) batch_size = batch[0].shape[0] - batch[0] = paddle.to_tensor(batch[0]).astype("float32") + batch[0] = paddle.to_tensor(batch[0]) if not engine.config["Global"].get("use_multilabel", False): batch[1] = batch[1].reshape([-1, 1]).astype("int64") -- GitLab