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

Function elu

dlib/cuda/cpu_dlib.cpp:2120–2135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2118 // ----------------------------------------------------------------------------------------
2119
2120 void elu (
2121 tensor& dest,
2122 const tensor& src,
2123 const float alpha
2124 )
2125 {
2126 const auto d = dest.host();
2127 const auto s = src.host();
2128 for (size_t i = 0; i < src.size(); ++i)
2129 {
2130 if (s[i] > 0)
2131 d[i] = s[i];
2132 else
2133 d[i] = alpha * (std::exp(s[i]) - 1.0f);
2134 }
2135 }
2136
2137 void elu_gradient (
2138 tensor& grad,

Callers 2

test_eluFunction · 0.50
forward_inplaceMethod · 0.50

Calls 3

expFunction · 0.85
hostMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_eluFunction · 0.40