From 14303717dcddae43cdc55beb0685dae86f566fd8 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Sat, 25 Oct 2014 18:57:26 +0000
Subject: [PATCH] Fast, needs to be faster
---
src/network.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/src/network.c b/src/network.c
index 6696769..5ea449c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -621,7 +621,7 @@
image *prev = 0;
int i;
char buff[256];
- show_image(get_network_image_layer(net, 0), "Crop");
+ //show_image(get_network_image_layer(net, 0), "Crop");
for(i = 0; i < net.n; ++i){
sprintf(buff, "Layer %d", i);
if(net.types[i] == CONVOLUTIONAL){
@@ -635,6 +635,27 @@
}
}
+void top_predictions(network net, int n, int *index)
+{
+ int i,j;
+ int k = get_network_output_size(net);
+ float *out = get_network_output(net);
+ float thresh = FLT_MAX;
+ for(i = 0; i < n; ++i){
+ float max = -FLT_MAX;
+ int max_i = -1;
+ for(j = 0; j < k; ++j){
+ float val = out[j];
+ if(val > max && val < thresh){
+ max = val;
+ max_i = j;
+ }
+ }
+ index[i] = max_i;
+ thresh = max;
+ }
+}
+
float *network_predict(network net, float *input)
{
forward_network(net, input, 0, 0);
--
Gitblit v1.10.0