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

Function leaky_relu

dlib/cuda/cpu_dlib.cpp:1994–2009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1992 // ------------------------------------------------------------------------------------
1993
1994 void leaky_relu (
1995 tensor& dest,
1996 const tensor& src,
1997 const float alpha
1998 )
1999 {
2000 const float* s = src.host();
2001 float* d = dest.host();
2002 for (size_t i = 0; i < dest.size(); ++i)
2003 {
2004 if (s[i] > 0)
2005 d[i] = s[i];
2006 else
2007 d[i] = alpha * s[i];
2008 }
2009 }
2010
2011 void leaky_relu_gradient (
2012 tensor& grad,

Callers 2

test_leaky_reluFunction · 0.50
forward_inplaceMethod · 0.50

Calls 2

hostMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_leaky_reluFunction · 0.40