#79629·Paddle

paddle.nn.functional.selu backward returns wrong finite gradient at x=-700

Author: ALinrunrunCreated Aug 6, 2026Updated Aug 6, 2026
Labelsstatus/new-issuetype/bug-report

bug描述 Describe the Bug

paddle.nn.functional.selu has an incorrect backward result for float64 input x = -700.0.

For SELU with the default constants, when x < 0, the derivative should be:

scale * alpha * exp(x)

At x = -700.0, the correct derivative is approximately:

1.7334290832552396e-304

This is a finite, normal float64 value. However, Paddle autograd returns -2.879237115394062e-08, which has the wrong magnitude and wrong sign.

Environment

  • PaddlePaddle version: 3.3.1
  • NumPy version: 2.2.6
  • dtype: float64
  • Device: CPU

Minimal reproducible code

python
import numpy as np
import paddle
import paddle.nn.functional as F

paddle.set_device("cpu")

x = paddle.to_tensor(
    -700.0,
    dtype="float64",
    stop_gradient=False,
)

y = F.selu(x)
y.backward()

wrong = float(x.grad)
expected = 1.7334290832552396e-304

print("wrong:", wrong)
print("expected:", expected)

Actual behavior

bash
wrong: -2.879237115394062e-08

Expected behavior

bash
expected: 1.7334290832552396e-304

paddle.nn.functional.selu backward should return scale * alpha * exp(x) for negative inputs.

For x = -700.0, the correct gradient is finite and representable in float64, but Paddle returns a much larger negative value.

其他补充信息 Additional Supplementary Information

No response