renamed sigmoid to logistic
| | |
| | | } |
| | | |
| | | __device__ float linear_activate_kernel(float x){return x;} |
| | | __device__ float sigmoid_activate_kernel(float x){return 1./(1. + exp(-x));} |
| | | __device__ float logistic_activate_kernel(float x){return 1./(1. + exp(-x));} |
| | | __device__ float relu_activate_kernel(float x){return x*(x>0);} |
| | | __device__ float ramp_activate_kernel(float x){return x*(x>0)+.1*x;} |
| | | __device__ float tanh_activate_kernel(float x){return (exp(2*x)-1)/(exp(2*x)+1);} |
| | | |
| | | __device__ float linear_gradient_kernel(float x){return 1;} |
| | | __device__ float sigmoid_gradient_kernel(float x){return (1-x)*x;} |
| | | __device__ float logistic_gradient_kernel(float x){return (1-x)*x;} |
| | | __device__ float relu_gradient_kernel(float x){return (x>0);} |
| | | __device__ float ramp_gradient_kernel(float x){return (x>0)+.1;} |
| | | __device__ float tanh_gradient_kernel(float x){return 1-x*x;} |
| | |
| | | switch(a){ |
| | | case LINEAR: |
| | | return linear_activate_kernel(x); |
| | | case SIGMOID: |
| | | return sigmoid_activate_kernel(x); |
| | | case LOGISTIC: |
| | | return logistic_activate_kernel(x); |
| | | case RELU: |
| | | return relu_activate_kernel(x); |
| | | case RAMP: |
| | |
| | | switch(a){ |
| | | case LINEAR: |
| | | return linear_gradient_kernel(x); |
| | | case SIGMOID: |
| | | return sigmoid_gradient_kernel(x); |
| | | case LOGISTIC: |
| | | return logistic_gradient_kernel(x); |
| | | case RELU: |
| | | return relu_gradient_kernel(x); |
| | | case RAMP: |
| | |
| | | char *get_activation_string(ACTIVATION a) |
| | | { |
| | | switch(a){ |
| | | case SIGMOID: |
| | | return "sigmoid"; |
| | | case LOGISTIC: |
| | | return "logistic"; |
| | | case RELU: |
| | | return "relu"; |
| | | case RAMP: |
| | |
| | | |
| | | ACTIVATION get_activation(char *s) |
| | | { |
| | | if (strcmp(s, "sigmoid")==0) return SIGMOID; |
| | | if (strcmp(s, "logistic")==0) return LOGISTIC; |
| | | if (strcmp(s, "relu")==0) return RELU; |
| | | if (strcmp(s, "linear")==0) return LINEAR; |
| | | if (strcmp(s, "ramp")==0) return RAMP; |
| | |
| | | switch(a){ |
| | | case LINEAR: |
| | | return linear_activate(x); |
| | | case SIGMOID: |
| | | return sigmoid_activate(x); |
| | | case LOGISTIC: |
| | | return logistic_activate(x); |
| | | case RELU: |
| | | return relu_activate(x); |
| | | case RAMP: |
| | |
| | | switch(a){ |
| | | case LINEAR: |
| | | return linear_gradient(x); |
| | | case SIGMOID: |
| | | return sigmoid_gradient(x); |
| | | case LOGISTIC: |
| | | return logistic_gradient(x); |
| | | case RELU: |
| | | return relu_gradient(x); |
| | | case RAMP: |
| | |
| | | #define ACTIVATIONS_H |
| | | |
| | | typedef enum{ |
| | | SIGMOID, RELU, LINEAR, RAMP, TANH |
| | | LOGISTIC, RELU, LINEAR, RAMP, TANH |
| | | }ACTIVATION; |
| | | |
| | | ACTIVATION get_activation(char *s); |
| | |
| | | #endif |
| | | |
| | | static inline float linear_activate(float x){return x;} |
| | | static inline float sigmoid_activate(float x){return 1./(1. + exp(-x));} |
| | | static inline float logistic_activate(float x){return 1./(1. + exp(-x));} |
| | | static inline float relu_activate(float x){return x*(x>0);} |
| | | static inline float ramp_activate(float x){return x*(x>0)+.1*x;} |
| | | static inline float tanh_activate(float x){return (exp(2*x)-1)/(exp(2*x)+1);} |
| | | |
| | | static inline float linear_gradient(float x){return 1;} |
| | | static inline float sigmoid_gradient(float x){return (1-x)*x;} |
| | | static inline float logistic_gradient(float x){return (1-x)*x;} |
| | | static inline float relu_gradient(float x){return (x>0);} |
| | | static inline float ramp_gradient(float x){return (x>0)+.1;} |
| | | static inline float tanh_gradient(float x){return 1-x*x;} |
| | |
| | | layer.output[out_i++] = scale*in[in_i++]; |
| | | } |
| | | softmax_array(layer.output + out_i - layer.classes, layer.classes, layer.output + out_i - layer.classes); |
| | | activate_array(in+in_i, layer.coords, SIGMOID); |
| | | activate_array(in+in_i, layer.coords, LOGISTIC); |
| | | for(j = 0; j < layer.coords; ++j){ |
| | | layer.output[out_i++] = mask*in[in_i++]; |
| | | } |
| | |
| | | delta[in_i++] = scale*layer.delta[out_i++]; |
| | | } |
| | | |
| | | gradient_array(layer.output + out_i, layer.coords, SIGMOID, layer.delta + out_i); |
| | | gradient_array(layer.output + out_i, layer.coords, LOGISTIC, layer.delta + out_i); |
| | | for(j = 0; j < layer.coords; ++j){ |
| | | delta[in_i++] = layer.delta[out_i++]; |
| | | } |
| | |
| | | int n = option_find_int(options, "filters",1); |
| | | int size = option_find_int(options, "size",1); |
| | | int stride = option_find_int(options, "stride",1); |
| | | char *activation_s = option_find_str(options, "activation", "sigmoid"); |
| | | char *activation_s = option_find_str(options, "activation", "logistic"); |
| | | ACTIVATION activation = get_activation(activation_s); |
| | | if(count == 0){ |
| | | learning_rate = option_find_float(options, "learning_rate", .001); |
| | |
| | | int size = option_find_int(options, "size",1); |
| | | int stride = option_find_int(options, "stride",1); |
| | | int pad = option_find_int(options, "pad",0); |
| | | char *activation_s = option_find_str(options, "activation", "sigmoid"); |
| | | char *activation_s = option_find_str(options, "activation", "logistic"); |
| | | ACTIVATION activation = get_activation(activation_s); |
| | | if(count == 0){ |
| | | learning_rate = option_find_float(options, "learning_rate", .001); |
| | |
| | | int input; |
| | | float learning_rate, momentum, decay; |
| | | int output = option_find_int(options, "output",1); |
| | | char *activation_s = option_find_str(options, "activation", "sigmoid"); |
| | | char *activation_s = option_find_str(options, "activation", "logistic"); |
| | | ACTIVATION activation = get_activation(activation_s); |
| | | if(count == 0){ |
| | | input = option_find_int(options, "input",1); |