Merge pull request #1 from AlexeyAB/master

Minor fix. Fixed forward MISH on CPU
This commit is contained in:
Muhammad Maaz 2020-03-01 11:48:48 +05:00 committed by GitHub
commit d392cbc622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View File

@ -61,7 +61,8 @@ static inline float selu_activate(float x) { return (x >= 0)*1.0507f*x + (x < 0)
static inline float relie_activate(float x){return (x>0) ? x : .01f*x;}
static inline float ramp_activate(float x){return x*(x>0)+.1f*x;}
static inline float leaky_activate(float x){return (x>0) ? x : .1f*x;}
static inline float tanh_activate(float x){return (expf(2*x)-1)/(expf(2*x)+1);}
//static inline float tanh_activate(float x){return (expf(2*x)-1)/(expf(2*x)+1);}
static inline float tanh_activate(float x) { return (2 / (1 + expf(-2 * x)) - 1); }
static inline float softplus_activate(float x, float threshold) {
if (x > threshold) return x; // too large
else if (x < -threshold) return expf(x); // too small

View File

@ -266,6 +266,13 @@ void forward_network(network net, network_state state)
l.forward(l, state);
//printf("%d - Predicted in %lf milli-seconds.\n", i, ((double)get_time_point() - time) / 1000);
state.input = l.output;
/*
float avg_val = 0;
int k;
for (k = 0; k < l.outputs; ++k) avg_val += l.output[k];
printf(" i: %d - avg_val = %f \n", i, avg_val / l.outputs);
*/
}
}

View File

@ -106,6 +106,16 @@ void forward_network_gpu(network net, network_state state)
cudaStreamSynchronize(get_cuda_stream());
state.input = l.output_gpu;
//cudaDeviceSynchronize();
/*
cuda_pull_array(l.output_gpu, l.output, l.outputs);
cudaStreamSynchronize(get_cuda_stream());
float avg_val = 0;
int k;
for (k = 0; k < l.outputs; ++k) avg_val += l.output[k];
printf(" i: %d - avg_val = %f \n", i, avg_val / l.outputs);
*/
/*
cuda_pull_array(l.output_gpu, l.output, l.batch*l.outputs);
if (l.out_w >= 0 && l.out_h >= 1 && l.c >= 3) {