Permalink
Browse files

Merge pull request #3410 from ghost/patch-2

sigmoid fix: calculate by tanh instead of exp (cpp)
  • Loading branch information...
2 parents 6137b24 + 52dcf48 commit 08bded8c037f5fdaf75928b7ed4ab8ea2809c96f @shelhamer shelhamer committed on GitHub Apr 14, 2017
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/caffe/layers/sigmoid_layer.cu
@@ -8,7 +8,7 @@ namespace caffe {
template <typename Dtype>
__global__ void SigmoidForward(const int n, const Dtype* in, Dtype* out) {
CUDA_KERNEL_LOOP(index, n) {
- out[index] = 1. / (1. + exp(-in[index]));
+ out[index] = 0.5 * tanh(0.5 * in[index]) + 0.5;
}
}

0 comments on commit 08bded8

Please sign in to comment.