Skip to content

Commit 1213014

Browse files
committed
add nnet.softplus() to NumPy backend
1 parent f4337e5 commit 1213014

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cudarray/numpy_backend/nnet/activations.py

+13
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ def relu_d(x, out=None):
3434
result = np.zeros(x.shape)
3535
result[x >= 0] = 1
3636
return _output(result, out)
37+
38+
39+
def softplus(x, out=None):
40+
result = np.log1p(np.exp(x))
41+
mask = x > 25.0
42+
result[mask] = x[mask]
43+
return _output(result, out)
44+
45+
46+
def softplus_d(x, out=None):
47+
result = 1.0 - 1.0/(1.0 + np.exp(x))
48+
result[x > 25.0] = 1.0
49+
return _output(result, out)

0 commit comments

Comments
 (0)