| | |
| | | #include "softmax_layer.h" |
| | | #include "dropout_layer.h" |
| | | #include "detection_layer.h" |
| | | #include "route_layer.h" |
| | | #include "list.h" |
| | | #include "option_list.h" |
| | | #include "utils.h" |
| | |
| | | int is_cost(section *s); |
| | | int is_detection(section *s); |
| | | int is_normalization(section *s); |
| | | int is_route(section *s); |
| | | list *read_cfg(char *filename); |
| | | |
| | | void free_section(section *s) |
| | |
| | | int crop_height = option_find_int(options, "crop_height",1); |
| | | int crop_width = option_find_int(options, "crop_width",1); |
| | | int flip = option_find_int(options, "flip",0); |
| | | float angle = option_find_float(options, "angle",0); |
| | | float saturation = option_find_float(options, "saturation",1); |
| | | float exposure = option_find_float(options, "exposure",1); |
| | | |
| | | int batch,h,w,c; |
| | | h = params.h; |
| | |
| | | batch=params.batch; |
| | | if(!(h && w && c)) error("Layer before crop layer must output image."); |
| | | |
| | | crop_layer *layer = make_crop_layer(batch,h,w,c,crop_height,crop_width,flip); |
| | | crop_layer *layer = make_crop_layer(batch,h,w,c,crop_height,crop_width,flip, angle, saturation, exposure); |
| | | option_unused(options); |
| | | return layer; |
| | | } |
| | |
| | | return layer; |
| | | } |
| | | |
| | | route_layer *parse_route(list *options, size_params params, network net) |
| | | { |
| | | char *l = option_find(options, "layers"); |
| | | int len = strlen(l); |
| | | if(!l) error("Route Layer must specify input layers"); |
| | | int n = 1; |
| | | int i; |
| | | for(i = 0; i < len; ++i){ |
| | | if (l[i] == ',') ++n; |
| | | } |
| | | |
| | | int *layers = calloc(n, sizeof(int)); |
| | | int *sizes = calloc(n, sizeof(int)); |
| | | for(i = 0; i < n; ++i){ |
| | | int index = atoi(l); |
| | | l = strchr(l, ',')+1; |
| | | layers[i] = index; |
| | | sizes[i] = get_network_output_size_layer(net, index); |
| | | } |
| | | int batch = params.batch; |
| | | |
| | | route_layer *layer = make_route_layer(batch, n, layers, sizes); |
| | | option_unused(options); |
| | | return layer; |
| | | } |
| | | |
| | | void parse_net_options(list *options, network *net) |
| | | { |
| | | net->batch = option_find_int(options, "batch",1); |
| | |
| | | normalization_layer *layer = parse_normalization(options, params); |
| | | net.types[count] = NORMALIZATION; |
| | | net.layers[count] = layer; |
| | | }else if(is_route(s)){ |
| | | route_layer *layer = parse_route(options, params, net); |
| | | net.types[count] = ROUTE; |
| | | net.layers[count] = layer; |
| | | }else if(is_dropout(s)){ |
| | | dropout_layer *layer = parse_dropout(options, params); |
| | | net.types[count] = DROPOUT; |
| | |
| | | return (strcmp(s->type, "[lrnorm]")==0 |
| | | || strcmp(s->type, "[localresponsenormalization]")==0); |
| | | } |
| | | int is_route(section *s) |
| | | { |
| | | return (strcmp(s->type, "[route]")==0); |
| | | } |
| | | |
| | | int read_option(char *s, list *options) |
| | | { |
| | |
| | | fread(&net->momentum, sizeof(float), 1, fp); |
| | | fread(&net->decay, sizeof(float), 1, fp); |
| | | fread(&net->seen, sizeof(int), 1, fp); |
| | | fprintf(stderr, "%f %f %f %d\n", net->learning_rate, net->momentum, net->decay, net->seen); |
| | | |
| | | int i; |
| | | for(i = 0; i < net->n && i < cutoff; ++i){ |