From 6d73091e14dfd44576521ea5317554457cfa02d1 Mon Sep 17 00:00:00 2001 From: wangruting Date: Sun, 12 Feb 2023 05:10:04 +0000 Subject: [PATCH] modify rules --- python/paddle/incubate/autograd/composite_rules.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/paddle/incubate/autograd/composite_rules.py b/python/paddle/incubate/autograd/composite_rules.py index 750e1219605..1d92d18cf34 100644 --- a/python/paddle/incubate/autograd/composite_rules.py +++ b/python/paddle/incubate/autograd/composite_rules.py @@ -33,8 +33,8 @@ def softmax_composite(x, axis): max_temp = max(x, axis, keepdim=True) max_temp.stop_gradient = True molecular = exp(x - max_temp) - sqrt_var = sum(molecular, axis=axis, keepdim=True) - res = divide(molecular, sqrt_var) + denominator = sum(molecular, axis=axis, keepdim=True) + res = divide(molecular, denominator) return res @@ -105,7 +105,7 @@ def composite_batchnorm( @REGISTER_COMPOSITE('layer_norm') def layernorm_composite(x, scale, bias, epsilon, begin_norm_axis): - axis = np.arange(begin_norm_axis, len(x.shape)) + axis = tuple(range(begin_norm_axis, len(x.shape))) mean_ = mean(x, axis=axis, keepdim=True) difference = x - mean_ var_tmp1 = pow(difference, 2.0) -- GitLab