| | |
| | | |
| | | #include "crop_layer.h" |
| | | #include "connected_layer.h" |
| | | #include "gru_layer.h" |
| | | #include "rnn_layer.h" |
| | | #include "crnn_layer.h" |
| | | #include "local_layer.h" |
| | | #include "convolutional_layer.h" |
| | | #include "activation_layer.h" |
| | | #include "deconvolutional_layer.h" |
| | | #include "detection_layer.h" |
| | | #include "normalization_layer.h" |
| | | #include "batchnorm_layer.h" |
| | | #include "maxpool_layer.h" |
| | | #include "avgpool_layer.h" |
| | | #include "cost_layer.h" |
| | |
| | | switch(a){ |
| | | case CONVOLUTIONAL: |
| | | return "convolutional"; |
| | | case ACTIVE: |
| | | return "activation"; |
| | | case LOCAL: |
| | | return "local"; |
| | | case DECONVOLUTIONAL: |
| | | return "deconvolutional"; |
| | | case CONNECTED: |
| | | return "connected"; |
| | | case RNN: |
| | | return "rnn"; |
| | | case GRU: |
| | | return "gru"; |
| | | case CRNN: |
| | | return "crnn"; |
| | | case MAXPOOL: |
| | | return "maxpool"; |
| | | case AVGPOOL: |
| | |
| | | return "shortcut"; |
| | | case NORMALIZATION: |
| | | return "normalization"; |
| | | case BATCHNORM: |
| | | return "batchnorm"; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | forward_convolutional_layer(l, state); |
| | | } else if(l.type == DECONVOLUTIONAL){ |
| | | forward_deconvolutional_layer(l, state); |
| | | } else if(l.type == ACTIVE){ |
| | | forward_activation_layer(l, state); |
| | | } else if(l.type == LOCAL){ |
| | | forward_local_layer(l, state); |
| | | } else if(l.type == NORMALIZATION){ |
| | | forward_normalization_layer(l, state); |
| | | } else if(l.type == BATCHNORM){ |
| | | forward_batchnorm_layer(l, state); |
| | | } else if(l.type == DETECTION){ |
| | | forward_detection_layer(l, state); |
| | | } else if(l.type == CONNECTED){ |
| | | forward_connected_layer(l, state); |
| | | } else if(l.type == RNN){ |
| | | forward_rnn_layer(l, state); |
| | | } else if(l.type == GRU){ |
| | | forward_gru_layer(l, state); |
| | | } else if(l.type == CRNN){ |
| | | forward_crnn_layer(l, state); |
| | | } else if(l.type == CROP){ |
| | | forward_crop_layer(l, state); |
| | | } else if(l.type == COST){ |
| | |
| | | update_deconvolutional_layer(l, rate, net.momentum, net.decay); |
| | | } else if(l.type == CONNECTED){ |
| | | update_connected_layer(l, update_batch, rate, net.momentum, net.decay); |
| | | } else if(l.type == RNN){ |
| | | update_rnn_layer(l, update_batch, rate, net.momentum, net.decay); |
| | | } else if(l.type == GRU){ |
| | | update_gru_layer(l, update_batch, rate, net.momentum, net.decay); |
| | | } else if(l.type == CRNN){ |
| | | update_crnn_layer(l, update_batch, rate, net.momentum, net.decay); |
| | | } else if(l.type == LOCAL){ |
| | | update_local_layer(l, update_batch, rate, net.momentum, net.decay); |
| | | } |
| | |
| | | |
| | | float *get_network_output(network net) |
| | | { |
| | | #ifdef GPU |
| | | return get_network_output_gpu(net); |
| | | #endif |
| | | int i; |
| | | for(i = net.n-1; i > 0; --i) if(net.layers[i].type != COST) break; |
| | | return net.layers[i].output; |
| | |
| | | int count = 0; |
| | | for(i = 0; i < net.n; ++i){ |
| | | if(net.layers[i].type == COST){ |
| | | sum += net.layers[i].output[0]; |
| | | sum += net.layers[i].cost[0]; |
| | | ++count; |
| | | } |
| | | if(net.layers[i].type == DETECTION){ |
| | |
| | | backward_convolutional_layer(l, state); |
| | | } else if(l.type == DECONVOLUTIONAL){ |
| | | backward_deconvolutional_layer(l, state); |
| | | } else if(l.type == ACTIVE){ |
| | | backward_activation_layer(l, state); |
| | | } else if(l.type == NORMALIZATION){ |
| | | backward_normalization_layer(l, state); |
| | | } else if(l.type == BATCHNORM){ |
| | | backward_batchnorm_layer(l, state); |
| | | } else if(l.type == MAXPOOL){ |
| | | if(i != 0) backward_maxpool_layer(l, state); |
| | | } else if(l.type == AVGPOOL){ |
| | |
| | | if(i != 0) backward_softmax_layer(l, state); |
| | | } else if(l.type == CONNECTED){ |
| | | backward_connected_layer(l, state); |
| | | } else if(l.type == RNN){ |
| | | backward_rnn_layer(l, state); |
| | | } else if(l.type == GRU){ |
| | | backward_gru_layer(l, state); |
| | | } else if(l.type == CRNN){ |
| | | backward_crnn_layer(l, state); |
| | | } else if(l.type == LOCAL){ |
| | | backward_local_layer(l, state); |
| | | } else if(l.type == COST){ |
| | |
| | | layer l = net->layers[i]; |
| | | if(l.type == CONVOLUTIONAL){ |
| | | resize_convolutional_layer(&l, w, h); |
| | | }else if(l.type == CROP){ |
| | | resize_crop_layer(&l, w, h); |
| | | }else if(l.type == MAXPOOL){ |
| | | resize_maxpool_layer(&l, w, h); |
| | | }else if(l.type == AVGPOOL){ |
| | | resize_avgpool_layer(&l, w, h); |
| | | break; |
| | | }else if(l.type == NORMALIZATION){ |
| | | resize_normalization_layer(&l, w, h); |
| | | }else if(l.type == COST){ |
| | |
| | | net->layers[i] = l; |
| | | w = l.out_w; |
| | | h = l.out_h; |
| | | if(l.type == AVGPOOL) break; |
| | | } |
| | | //fprintf(stderr, " Done!\n"); |
| | | return 0; |