From 08b757a0bf76efe8c76b453063a1bb19315bcaa6 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 14 Jan 2015 20:18:57 +0000
Subject: [PATCH] Stable, needs to be way faster

---
 src/parser.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/parser.c b/src/parser.c
index 79d4a3a..768f48b 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -16,6 +16,7 @@
 #include "list.h"
 #include "option_list.h"
 #include "utils.h"
+#include "opencl.h"
 
 typedef struct{
     char *type;
@@ -165,7 +166,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;
 }
@@ -243,6 +246,12 @@
     if(count == 0){
         net->batch = option_find_int(options, "batch",1);
         input = option_find_int(options, "input",1);
+        float learning_rate = option_find_float(options, "learning_rate", .001);
+        float momentum = option_find_float(options, "momentum", .9);
+        float decay = option_find_float(options, "decay", .0001);
+        net->learning_rate = learning_rate;
+        net->momentum = momentum;
+        net->decay = decay;
     }else{
         input =  get_network_output_size_layer(*net, count-1);
     }
@@ -379,8 +388,8 @@
 
 int read_option(char *s, list *options)
 {
-    int i;
-    int len = strlen(s);
+    size_t i;
+    size_t len = strlen(s);
     char *val = 0;
     for(i = 0; i < len; ++i){
         if(s[i] == '='){
@@ -432,6 +441,9 @@
 
 void print_convolutional_cfg(FILE *fp, convolutional_layer *l, network net, int count)
 {
+    #ifdef GPU
+    if(gpu_index >= 0) pull_convolutional_layer(*l);
+    #endif
     int i;
     fprintf(fp, "[convolutional]\n");
     if(count == 0) {
@@ -486,6 +498,9 @@
 
 void print_connected_cfg(FILE *fp, connected_layer *l, network net, int count)
 {
+    #ifdef GPU
+    if(gpu_index >= 0) pull_connected_layer(*l);
+    #endif
     int i;
     fprintf(fp, "[connected]\n");
     if(count == 0){
@@ -565,7 +580,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