From 23955b9fa0a29465ad2a2d13c445b49e6d5adef2 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Mon, 08 Feb 2016 19:50:45 +0000
Subject: [PATCH] binary reading weights

---
 src/network.c |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/src/network.c b/src/network.c
index d9585c4..32c3ba1 100644
--- a/src/network.c
+++ b/src/network.c
@@ -8,8 +8,10 @@
 
 #include "crop_layer.h"
 #include "connected_layer.h"
+#include "rnn_layer.h"
 #include "local_layer.h"
 #include "convolutional_layer.h"
+#include "activation_layer.h"
 #include "deconvolutional_layer.h"
 #include "detection_layer.h"
 #include "normalization_layer.h"
@@ -19,6 +21,7 @@
 #include "softmax_layer.h"
 #include "dropout_layer.h"
 #include "route_layer.h"
+#include "shortcut_layer.h"
 
 int get_current_batch(network net)
 {
@@ -72,12 +75,16 @@
     switch(a){
         case CONVOLUTIONAL:
             return "convolutional";
+        case ACTIVE:
+            return "activation";
         case LOCAL:
             return "local";
         case DECONVOLUTIONAL:
             return "deconvolutional";
         case CONNECTED:
             return "connected";
+        case RNN:
+            return "rnn";
         case MAXPOOL:
             return "maxpool";
         case AVGPOOL:
@@ -94,6 +101,8 @@
             return "cost";
         case ROUTE:
             return "route";
+        case SHORTCUT:
+            return "shortcut";
         case NORMALIZATION:
             return "normalization";
         default:
@@ -119,6 +128,7 @@
 {
     int i;
     for(i = 0; i < net.n; ++i){
+        state.index = i;
         layer l = net.layers[i];
         if(l.delta){
             scal_cpu(l.outputs * l.batch, 0, l.delta, 1);
@@ -127,6 +137,8 @@
             forward_convolutional_layer(l, state);
         } else if(l.type == DECONVOLUTIONAL){
             forward_deconvolutional_layer(l, state);
+        } else if(l.type == ACTIVE){
+            forward_activation_layer(l, state);
         } else if(l.type == LOCAL){
             forward_local_layer(l, state);
         } else if(l.type == NORMALIZATION){
@@ -135,6 +147,8 @@
             forward_detection_layer(l, state);
         } else if(l.type == CONNECTED){
             forward_connected_layer(l, state);
+        } else if(l.type == RNN){
+            forward_rnn_layer(l, state);
         } else if(l.type == CROP){
             forward_crop_layer(l, state);
         } else if(l.type == COST){
@@ -149,6 +163,8 @@
             forward_dropout_layer(l, state);
         } else if(l.type == ROUTE){
             forward_route_layer(l, net);
+        } else if(l.type == SHORTCUT){
+            forward_shortcut_layer(l, state);
         }
         state.input = l.output;
     }
@@ -167,6 +183,8 @@
             update_deconvolutional_layer(l, rate, net.momentum, net.decay);
         } else if(l.type == CONNECTED){
             update_connected_layer(l, update_batch, rate, net.momentum, net.decay);
+        } else if(l.type == RNN){
+            update_rnn_layer(l, update_batch, rate, net.momentum, net.decay);
         } else if(l.type == LOCAL){
             update_local_layer(l, update_batch, rate, net.momentum, net.decay);
         }
@@ -211,6 +229,7 @@
     float *original_input = state.input;
     float *original_delta = state.delta;
     for(i = net.n-1; i >= 0; --i){
+        state.index = i;
         if(i == 0){
             state.input = original_input;
             state.delta = original_delta;
@@ -224,6 +243,8 @@
             backward_convolutional_layer(l, state);
         } else if(l.type == DECONVOLUTIONAL){
             backward_deconvolutional_layer(l, state);
+        } else if(l.type == ACTIVE){
+            backward_activation_layer(l, state);
         } else if(l.type == NORMALIZATION){
             backward_normalization_layer(l, state);
         } else if(l.type == MAXPOOL){
@@ -238,12 +259,16 @@
             if(i != 0) backward_softmax_layer(l, state);
         } else if(l.type == CONNECTED){
             backward_connected_layer(l, state);
+        } else if(l.type == RNN){
+            backward_rnn_layer(l, state);
         } else if(l.type == LOCAL){
             backward_local_layer(l, state);
         } else if(l.type == COST){
             backward_cost_layer(l, state);
         } else if(l.type == ROUTE){
             backward_route_layer(l, net);
+        } else if(l.type == SHORTCUT){
+            backward_shortcut_layer(l, state);
         }
     }
 }
@@ -255,6 +280,8 @@
     if(gpu_index >= 0) return train_network_datum_gpu(net, x, y);
 #endif
     network_state state;
+    state.index = 0;
+    state.net = net;
     state.input = x;
     state.delta = 0;
     state.truth = y;
@@ -307,6 +334,8 @@
 {
     int i,j;
     network_state state;
+    state.index = 0;
+    state.net = net;
     state.train = 1;
     state.delta = 0;
     float sum = 0;
@@ -347,11 +376,12 @@
         layer l = net->layers[i];
         if(l.type == CONVOLUTIONAL){
             resize_convolutional_layer(&l, w, h);
+        }else if(l.type == CROP){
+            resize_crop_layer(&l, w, h);
         }else if(l.type == MAXPOOL){
             resize_maxpool_layer(&l, w, h);
         }else if(l.type == AVGPOOL){
             resize_avgpool_layer(&l, w, h);
-            break;
         }else if(l.type == NORMALIZATION){
             resize_normalization_layer(&l, w, h);
         }else if(l.type == COST){
@@ -363,6 +393,7 @@
         net->layers[i] = l;
         w = l.out_w;
         h = l.out_h;
+        if(l.type == AVGPOOL) break;
     }
     //fprintf(stderr, " Done!\n");
     return 0;
@@ -443,6 +474,8 @@
 #endif
 
     network_state state;
+    state.net = net;
+    state.index = 0;
     state.input = input;
     state.truth = 0;
     state.train = 0;

--
Gitblit v1.10.0