From 4bdf96bd6aafbec6bc3f0eab8739d6652878fd24 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Fri, 06 Dec 2013 21:26:09 +0000
Subject: [PATCH] New data format
---
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