| | |
| | | #include "dropout_layer.h" |
| | | #include "params.h" |
| | | #include "utils.h" |
| | | #include "cuda.h" |
| | | #include <stdlib.h> |
| | |
| | | |
| | | dropout_layer make_dropout_layer(int batch, int inputs, float probability) |
| | | { |
| | | fprintf(stderr, "Dropout Layer: %d inputs, %f probability\n", inputs, probability); |
| | | dropout_layer l = {0}; |
| | | l.type = DROPOUT; |
| | | l.probability = probability; |
| | |
| | | l.batch = batch; |
| | | l.rand = calloc(inputs*batch, sizeof(float)); |
| | | l.scale = 1./(1.-probability); |
| | | l.forward = forward_dropout_layer; |
| | | l.backward = backward_dropout_layer; |
| | | #ifdef GPU |
| | | l.forward_gpu = forward_dropout_layer_gpu; |
| | | l.backward_gpu = backward_dropout_layer_gpu; |
| | | l.rand_gpu = cuda_make_array(l.rand, inputs*batch); |
| | | #endif |
| | | fprintf(stderr, "dropout p = %.2f %4d -> %4d\n", probability, inputs, inputs); |
| | | return l; |
| | | } |
| | | |