From a6b2511a566f77a0838dc1dd0d5f3e3c49a8faa0 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Sat, 25 Jun 2016 23:13:54 +0000
Subject: [PATCH] idk

---
 src/activation_kernels.cu |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/activation_kernels.cu b/src/activation_kernels.cu
index 3dc3af0..5d61529 100644
--- a/src/activation_kernels.cu
+++ b/src/activation_kernels.cu
@@ -7,6 +7,25 @@
 #include "cuda.h"
 }
 
+
+__device__ float lhtan_activate_kernel(float x)
+{
+    if(x < 0) return .001*x;
+    if(x > 1) return .001*(x-1) + 1;
+    return x;
+}
+__device__ float lhtan_gradient_kernel(float x)
+{
+    if(x > 0 && x < 1) return 1;
+    return .001;
+}
+
+__device__ float hardtan_activate_kernel(float x)
+{
+    if (x < -1) return -1;
+    if (x > 1) return 1;
+    return x;
+}
 __device__ float linear_activate_kernel(float x){return x;}
 __device__ float logistic_activate_kernel(float x){return 1./(1. + exp(-x));}
 __device__ float loggy_activate_kernel(float x){return 2./(1. + exp(-x)) - 1;}
@@ -29,6 +48,12 @@
     else return (x - n) + floor(x/2.);
 }
  
+
+__device__ float hardtan_gradient_kernel(float x)
+{
+    if (x > -1 && x < 1) return 1;
+    return 0;
+}
 __device__ float linear_gradient_kernel(float x){return 1;}
 __device__ float logistic_gradient_kernel(float x){return (1-x)*x;}
 __device__ float loggy_gradient_kernel(float x)
@@ -74,6 +99,10 @@
             return plse_activate_kernel(x);
         case STAIR:
             return stair_activate_kernel(x);
+        case HARDTAN:
+            return hardtan_activate_kernel(x);
+        case LHTAN:
+            return lhtan_activate_kernel(x);
     }
     return 0;
 }
@@ -103,6 +132,10 @@
             return plse_gradient_kernel(x);
         case STAIR:
             return stair_gradient_kernel(x);
+        case HARDTAN:
+            return hardtan_gradient_kernel(x);
+        case LHTAN:
+            return lhtan_gradient_kernel(x);
     }
     return 0;
 }

--
Gitblit v1.10.0