MCPcopy Create free account
hub / github.com/davisking/dlib / smelu

Function smelu

dlib/cuda/cpu_dlib.cpp:2212–2229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2210 // ----------------------------------------------------------------------------------------
2211
2212 void smelu (
2213 tensor& dest,
2214 const tensor& src,
2215 const float beta
2216 )
2217 {
2218 const float* s = src.host();
2219 float* d = dest.host();
2220 for (size_t i = 0; i < dest.size(); ++i)
2221 {
2222 if (s[i] >= beta)
2223 d[i] = s[i];
2224 else if (s[i] <= -beta)
2225 d[i] = 0;
2226 else
2227 d[i] = (s[i] + beta) * (s[i] + beta) / (4 * beta);
2228 }
2229 }
2230
2231 void smelu_gradient (
2232 tensor& grad,

Callers 2

test_smeluFunction · 0.50
forward_inplaceMethod · 0.50

Calls 2

hostMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_smeluFunction · 0.40