Joseph Redmon
2014-12-08 cb1f33c6ae840e8dc0f43518daf76e6ed01034f0
src/network.c
@@ -213,7 +213,7 @@
        }
        if(net.types[i] == CONVOLUTIONAL){
            convolutional_layer layer = *(convolutional_layer *)net.layers[i];
            backward_convolutional_layer(layer, prev_delta);
            backward_convolutional_layer(layer, prev_input, prev_delta);
        }
        else if(net.types[i] == MAXPOOL){
            maxpool_layer layer = *(maxpool_layer *)net.layers[i];
@@ -476,25 +476,11 @@
    } 
}
void top_predictions(network net, int n, int *index)
void top_predictions(network net, int k, int *index)
{
    int i,j;
    int k = get_network_output_size(net);
    int size = 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;
    }
    top_k(out, size, k, index);
}