| | |
| | | #include <stdlib.h> |
| | | |
| | | #include "parser.h" |
| | | #include "assert.h" |
| | | #include "activations.h" |
| | | #include "crop_layer.h" |
| | | #include "cost_layer.h" |
| | |
| | | #include "gru_layer.h" |
| | | #include "crnn_layer.h" |
| | | #include "maxpool_layer.h" |
| | | #include "reorg_layer.h" |
| | | #include "softmax_layer.h" |
| | | #include "dropout_layer.h" |
| | | #include "detection_layer.h" |
| | |
| | | int is_gru(section *s); |
| | | int is_crnn(section *s); |
| | | int is_maxpool(section *s); |
| | | int is_reorg(section *s); |
| | | int is_avgpool(section *s); |
| | | int is_dropout(section *s); |
| | | int is_softmax(section *s); |
| | |
| | | |
| | | deconvolutional_layer layer = make_deconvolutional_layer(batch,h,w,c,n,size,stride,activation); |
| | | |
| | | char *weights = option_find_str(options, "weights", 0); |
| | | char *biases = option_find_str(options, "biases", 0); |
| | | parse_data(weights, layer.filters, c*n*size*size); |
| | | parse_data(biases, layer.biases, n); |
| | | #ifdef GPU |
| | | if(weights || biases) push_deconvolutional_layer(layer); |
| | | #endif |
| | | return layer; |
| | | } |
| | | |
| | |
| | | layer.flipped = option_find_int_quiet(options, "flipped", 0); |
| | | layer.dot = option_find_float_quiet(options, "dot", 0); |
| | | |
| | | char *weights = option_find_str(options, "weights", 0); |
| | | char *biases = option_find_str(options, "biases", 0); |
| | | parse_data(weights, layer.filters, c*n*size*size); |
| | | parse_data(biases, layer.biases, n); |
| | | #ifdef GPU |
| | | if(weights || biases) push_convolutional_layer(layer); |
| | | #endif |
| | | return layer; |
| | | } |
| | | |
| | |
| | | |
| | | connected_layer layer = make_connected_layer(params.batch, params.inputs, output, activation, batch_normalize); |
| | | |
| | | char *weights = option_find_str(options, "weights", 0); |
| | | char *biases = option_find_str(options, "biases", 0); |
| | | parse_data(biases, layer.biases, output); |
| | | parse_data(weights, layer.weights, params.inputs*output); |
| | | #ifdef GPU |
| | | if(weights || biases) push_connected_layer(layer); |
| | | #endif |
| | | return layer; |
| | | } |
| | | |
| | |
| | | layer.class_scale = option_find_float(options, "class_scale", 1); |
| | | layer.jitter = option_find_float(options, "jitter", .2); |
| | | layer.random = option_find_int_quiet(options, "random", 0); |
| | | layer.reorg = option_find_int_quiet(options, "reorg", 0); |
| | | return layer; |
| | | } |
| | | |
| | |
| | | return l; |
| | | } |
| | | |
| | | layer parse_reorg(list *options, size_params params) |
| | | { |
| | | int stride = option_find_int(options, "stride",1); |
| | | |
| | | int batch,h,w,c; |
| | | h = params.h; |
| | | w = params.w; |
| | | c = params.c; |
| | | batch=params.batch; |
| | | if(!(h && w && c)) error("Layer before reorg layer must output image."); |
| | | |
| | | layer layer = make_reorg_layer(batch,w,h,c,stride); |
| | | return layer; |
| | | } |
| | | |
| | | maxpool_layer parse_maxpool(list *options, size_params params) |
| | | { |
| | | int stride = option_find_int(options, "stride",1); |
| | |
| | | l = parse_batchnorm(options, params); |
| | | }else if(is_maxpool(s)){ |
| | | l = parse_maxpool(options, params); |
| | | }else if(is_reorg(s)){ |
| | | l = parse_reorg(options, params); |
| | | }else if(is_avgpool(s)){ |
| | | l = parse_avgpool(options, params); |
| | | }else if(is_route(s)){ |
| | |
| | | if(workspace_size){ |
| | | //printf("%ld\n", workspace_size); |
| | | #ifdef GPU |
| | | if(gpu_index >= 0){ |
| | | net.workspace = cuda_make_array(0, (workspace_size-1)/sizeof(float)+1); |
| | | }else { |
| | | net.workspace = calloc(1, workspace_size); |
| | | } |
| | | #else |
| | | net.workspace = calloc(1, workspace_size); |
| | | #endif |
| | |
| | | || strcmp(type, "[connected]")==0) return CONNECTED; |
| | | if (strcmp(type, "[max]")==0 |
| | | || strcmp(type, "[maxpool]")==0) return MAXPOOL; |
| | | if (strcmp(type, "[reorg]")==0) return REORG; |
| | | if (strcmp(type, "[avg]")==0 |
| | | || strcmp(type, "[avgpool]")==0) return AVGPOOL; |
| | | if (strcmp(type, "[dropout]")==0) return DROPOUT; |
| | |
| | | return (strcmp(s->type, "[conn]")==0 |
| | | || strcmp(s->type, "[connected]")==0); |
| | | } |
| | | int is_reorg(section *s) |
| | | { |
| | | return (strcmp(s->type, "[reorg]")==0); |
| | | } |
| | | int is_maxpool(section *s) |
| | | { |
| | | return (strcmp(s->type, "[max]")==0 |