From 20a611cf78944cecca0fa594c8749e6f94b7cbb8 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Wed, 30 Oct 2019 12:06:35 +0800 Subject: [PATCH] Fix mixed precision training of senet backbone (#8) --- ppdet/modeling/backbones/senet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ppdet/modeling/backbones/senet.py b/ppdet/modeling/backbones/senet.py index 09c69ff19..3219f6940 100644 --- a/ppdet/modeling/backbones/senet.py +++ b/ppdet/modeling/backbones/senet.py @@ -21,6 +21,7 @@ import math from paddle import fluid from paddle.fluid.param_attr import ParamAttr +from ppdet.experimental import mixed_precision_global_state from ppdet.core.workspace import register, serializable from .resnext import ResNeXt @@ -72,12 +73,13 @@ class SENet(ResNeXt): self.dcn_v2_stages = dcn_v2_stages def _squeeze_excitation(self, input, num_channels, name=None): + mixed_precision_enabled = mixed_precision_global_state() is not None pool = fluid.layers.pool2d( input=input, pool_size=0, pool_type='avg', global_pooling=True, - use_cudnn=False) + use_cudnn=mixed_precision_enabled) stdv = 1.0 / math.sqrt(pool.shape[1] * 1.0) squeeze = fluid.layers.fc( input=pool, -- GitLab