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

Function tanh_gradient

dlib/cuda/cudnn_dlibapi.cpp:1995–2021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1993 }
1994
1995 void tanh_gradient (
1996 tensor& grad,
1997 const tensor& dest,
1998 const tensor& gradient_input
1999 )
2000 {
2001 DLIB_CASSERT(
2002 have_same_dimensions(dest,gradient_input) == true &&
2003 have_same_dimensions(dest,grad) == true);
2004 if (dest.size() == 0)
2005 return;
2006
2007 const float alpha = 1;
2008 const float beta = is_same_object(grad,gradient_input) ? 0 : 1;
2009 CHECK_CUDNN(cudnnActivationBackward(context(),
2010 tanh_activation_descriptor(),
2011 &alpha,
2012 descriptor(dest),
2013 dest.device(),
2014 descriptor(gradient_input),
2015 gradient_input.device(),
2016 descriptor(dest),
2017 dest.device(),
2018 &beta,
2019 descriptor(grad),
2020 grad.device()));
2021 }
2022
2023 // ------------------------------------------------------------------------------------
2024

Callers

nothing calls this directly

Calls 7

descriptorFunction · 0.85
have_same_dimensionsFunction · 0.70
contextFunction · 0.70
is_same_objectFunction · 0.50
sizeMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected