| | |
| | | l.biases = calloc(outputs, sizeof(float)); |
| | | |
| | | |
| | | float scale = 1./sqrt(inputs); |
| | | //float scale = 1./sqrt(inputs); |
| | | float scale = sqrt(2./inputs); |
| | | for(i = 0; i < inputs*outputs; ++i){ |
| | | l.weights[i] = 2*scale*rand_uniform() - scale; |
| | | } |
| | |
| | | b = l.weights; |
| | | c = state.delta; |
| | | |
| | | if(c) gemm(0,1,m,n,k,1,a,k,b,k,0,c,n); |
| | | if(c) gemm(0,1,m,n,k,1,a,k,b,k,1,c,n); |
| | | } |
| | | |
| | | #ifdef GPU |
| | |
| | | float * c = l.output_gpu; |
| | | gemm_ongpu(0,0,m,n,k,1,a,k,b,n,1,c,n); |
| | | activate_array_ongpu(l.output_gpu, l.outputs*l.batch, l.activation); |
| | | |
| | | /* |
| | | cuda_pull_array(l.output_gpu, l.output, l.outputs*l.batch); |
| | | float avg = mean_array(l.output, l.outputs*l.batch); |
| | | printf("%f\n", avg); |
| | | */ |
| | | } |
| | | |
| | | void backward_connected_layer_gpu(connected_layer l, network_state state) |
| | |
| | | b = l.weights_gpu; |
| | | c = state.delta; |
| | | |
| | | if(c) gemm_ongpu(0,1,m,n,k,1,a,k,b,k,0,c,n); |
| | | if(c) gemm_ongpu(0,1,m,n,k,1,a,k,b,k,1,c,n); |
| | | } |
| | | #endif |