From cb1f33c6ae840e8dc0f43518daf76e6ed01034f0 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Mon, 08 Dec 2014 19:48:57 +0000
Subject: [PATCH] Fixed race condition in server

---
 src/parser.c |   50 +++++++++++---------------------------------------
 1 files changed, 11 insertions(+), 39 deletions(-)

diff --git a/src/parser.c b/src/parser.c
index 9bd2eb7..2069753 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -67,7 +67,6 @@
 
 convolutional_layer *parse_convolutional(list *options, network *net, int count)
 {
-    int i;
     int h,w,c;
     float learning_rate, momentum, decay;
     int n = option_find_int(options, "filters",1);
@@ -98,34 +97,19 @@
         if(h == 0) error("Layer before convolutional layer must output image.");
     }
     convolutional_layer *layer = make_convolutional_layer(net->batch,h,w,c,n,size,stride,pad,activation,learning_rate,momentum,decay);
-    char *data = option_find_str(options, "data", 0);
-    if(data){
-        char *curr = data;
-        char *next = data;
-        for(i = 0; i < n; ++i){
-            while(*++next !='\0' && *next != ',');
-            *next = '\0';
-            sscanf(curr, "%g", &layer->biases[i]);
-            curr = next+1;
-        }
-        for(i = 0; i < c*n*size*size; ++i){
-            while(*++next !='\0' && *next != ',');
-            *next = '\0';
-            sscanf(curr, "%g", &layer->filters[i]);
-            curr = next+1;
-        }
-    }
     char *weights = option_find_str(options, "weights", 0);
     char *biases = option_find_str(options, "biases", 0);
-    parse_data(biases, layer->biases, n);
     parse_data(weights, layer->filters, c*n*size*size);
+    parse_data(biases, layer->biases, n);
+    #ifdef GPU
+    push_convolutional_layer(*layer);
+    #endif
     option_unused(options);
     return layer;
 }
 
 connected_layer *parse_connected(list *options, network *net, int count)
 {
-    int i;
     int input;
     float learning_rate, momentum, decay;
     int output = option_find_int(options, "output",1);
@@ -147,27 +131,13 @@
         input =  get_network_output_size_layer(*net, count-1);
     }
     connected_layer *layer = make_connected_layer(net->batch, input, output, activation,learning_rate,momentum,decay);
-    char *data = option_find_str(options, "data", 0);
-    if(data){
-        char *curr = data;
-        char *next = data;
-        for(i = 0; i < output; ++i){
-            while(*++next !='\0' && *next != ',');
-            *next = '\0';
-            sscanf(curr, "%g", &layer->biases[i]);
-            curr = next+1;
-        }
-        for(i = 0; i < input*output; ++i){
-            while(*++next !='\0' && *next != ',');
-            *next = '\0';
-            sscanf(curr, "%g", &layer->weights[i]);
-            curr = next+1;
-        }
-    }
     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, input*output);
+    #ifdef GPU
+    push_connected_layer(*layer);
+    #endif
     option_unused(options);
     return layer;
 }
@@ -195,7 +165,9 @@
     }else{
         input =  get_network_output_size_layer(*net, count-1);
     }
-    cost_layer *layer = make_cost_layer(net->batch, input);
+    char *type_s = option_find_str(options, "type", "sse");
+    COST_TYPE type = get_cost_type(type_s);
+    cost_layer *layer = make_cost_layer(net->batch, input, type);
     option_unused(options);
     return layer;
 }
@@ -595,7 +567,7 @@
 
 void print_cost_cfg(FILE *fp, cost_layer *l, network net, int count)
 {
-    fprintf(fp, "[cost]\n");
+    fprintf(fp, "[cost]\ntype=%s\n", get_cost_string(l->type));
     if(count == 0) fprintf(fp, "batch=%d\ninput=%d\n", l->batch, l->inputs);
     fprintf(fp, "\n");
 }

--
Gitblit v1.10.0