mirror of https://github.com/Jittor/Jittor
polish sigmoid nan
This commit is contained in:
parent
8616c01a74
commit
8978e7dcd1
|
@ -8,7 +8,7 @@
|
|||
# This file is subject to the terms and conditions defined in
|
||||
# file 'LICENSE.txt', which is part of this source code package.
|
||||
# ***************************************************************
|
||||
__version__ = '1.2.2.42'
|
||||
__version__ = '1.2.2.43'
|
||||
from . import lock
|
||||
with lock.lock_scope():
|
||||
ori_int = int
|
||||
|
|
|
@ -62,6 +62,13 @@ class TestUnaryOp(unittest.TestCase):
|
|||
jda = jt.grad(jb, ja)
|
||||
assert (np.allclose(jda.data, da)), (jda.data,da,op)
|
||||
|
||||
def test_sigmoid(self):
|
||||
a = np.arange(-150,150, 10).astype("float32")
|
||||
# a = np.array([-150.0, -140.0, -130.0]).astype("float32")
|
||||
b = jt.array(a, dtype='float32')
|
||||
b1 = b.sigmoid().numpy()
|
||||
assert np.isnan(b1).any() == False
|
||||
|
||||
class TestUnaryOpCuda(TestUnaryOp, test_cuda(2)):
|
||||
pass
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace jittor {
|
|||
#define tanh(T,x) ((T) ::tanhf((x)))
|
||||
#define atanh(T,x) ((T) ::atanhf((x)))
|
||||
|
||||
#define sigmoid(T,x) ((T) (1.0f/(1.0f+::expf(-(x)))))
|
||||
#define sigmoid(T,x) ((T) (1.0f/(1.0f+::expf((::min(T(-(x)), T(@if(@strcmp(@T,float32)==0,30,300))))))))
|
||||
|
||||
#define erf(T,x) ((T) ::erff((x)))
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace jittor {
|
|||
#define tanh(T,x) ((T) std::tanh((x)))
|
||||
#define atanh(T,x) ((T) std::atanh((x)))
|
||||
|
||||
#define sigmoid(T,x) ((T) (1.0f/(1.0f+std::exp(-(x)))))
|
||||
#define sigmoid(T,x) ((T) (1.0f/(1.0f+std::exp(std::min(T(-(x)), T(@if(@strcmp(@T,float32)==0,30,300)))))))
|
||||
|
||||
#define erf(T,x) ((T) std::erf((x)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue