From 1d53b6414e0cd81043d7c76aa89f4f97da5e479f Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Thu, 23 Jan 2014 19:24:37 +0000
Subject: [PATCH] Stable on MNIST, about to change a lot

---
 src/parser.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/parser.c b/src/parser.c
index 7541620..eeb6f93 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -7,6 +7,7 @@
 #include "convolutional_layer.h"
 #include "connected_layer.h"
 #include "maxpool_layer.h"
+#include "softmax_layer.h"
 #include "list.h"
 #include "option_list.h"
 #include "utils.h"
@@ -19,6 +20,7 @@
 int is_convolutional(section *s);
 int is_connected(section *s);
 int is_maxpool(section *s);
+int is_softmax(section *s);
 list *read_cfg(char *filename);
 
 
@@ -69,6 +71,17 @@
             net.types[count] = CONNECTED;
             net.layers[count] = layer;
             option_unused(options);
+        }else if(is_softmax(s)){
+            int input;
+            if(count == 0){
+                input = option_find_int(options, "input",1);
+            }else{
+                input =  get_network_output_size_layer(net, count-1);
+            }
+            softmax_layer *layer = make_softmax_layer(input);
+            net.types[count] = SOFTMAX;
+            net.layers[count] = layer;
+            option_unused(options);
         }else if(is_maxpool(s)){
             int h,w,c;
             int stride = option_find_int(options, "stride",1);
@@ -94,6 +107,8 @@
         ++count;
         n = n->next;
     }   
+    net.outputs = get_network_output_size(net);
+    net.output = get_network_output(net);
     return net;
 }
 
@@ -113,6 +128,12 @@
             || strcmp(s->type, "[maxpool]")==0);
 }
 
+int is_softmax(section *s)
+{
+    return (strcmp(s->type, "[soft]")==0
+            || strcmp(s->type, "[softmax]")==0);
+}
+
 int read_option(char *s, list *options)
 {
     int i;

--
Gitblit v1.10.0