From 2ce6460c79e06caa33eab3991ee3e7fd9f0909d6 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Tue, 10 Apr 2018 18:08:24 +0000
Subject: [PATCH] Remove truth only if smaller than 1x1 pix during training

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

diff --git a/src/network.c b/src/network.c
index 51d290c..438829a 100644
--- a/src/network.c
+++ b/src/network.c
@@ -543,7 +543,7 @@
 	float **probs = calloc(l.w*l.h*l.n, sizeof(float *));
 	int i, j;
 	for (j = 0; j < l.w*l.h*l.n; ++j) probs[j] = calloc(l.classes, sizeof(float *));
-	get_region_boxes(l, w, h, thresh, probs, boxes, 0, map);
+	get_region_boxes(l, 1, 1, thresh, probs, boxes, 0, map);
 	for (j = 0; j < l.w*l.h*l.n; ++j) {
 		dets[j].classes = l.classes;
 		dets[j].bbox = boxes[j];
@@ -748,3 +748,42 @@
 	free(net.workspace);
 #endif
 }
+
+
+void fuse_conv_batchnorm(network net)
+{
+	int j;
+	for (j = 0; j < net.n; ++j) {
+		layer *l = &net.layers[j];
+
+		if (l->type == CONVOLUTIONAL) {
+			//printf(" Merges Convolutional-%d and batch_norm \n", j);
+
+			if (l->batch_normalize) {
+				int f;
+				for (f = 0; f < l->n; ++f)
+				{
+					l->biases[f] = l->biases[f] - l->scales[f] * l->rolling_mean[f] / (sqrtf(l->rolling_variance[f]) + .000001f);
+
+					const size_t filter_size = l->size*l->size*l->c;
+					int i;
+					for (i = 0; i < filter_size; ++i) {
+						int w_index = f*filter_size + i;
+
+						l->weights[w_index] = l->weights[w_index] * l->scales[f] / (sqrtf(l->rolling_variance[f]) + .000001f);
+					}
+				}
+
+				l->batch_normalize = 0;
+#ifdef GPU
+				if (gpu_index >= 0) {
+					push_convolutional_layer(*l);
+				}
+#endif
+			}
+		}
+		else {
+			//printf(" Fusion skip layer type: %d \n", l->type);
+		}
+	}
+}

--
Gitblit v1.10.0