stupid uninitialized variable in the mlp training caught by cppcheck
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Sat, 9 Nov 2013 02:47:44 +0000 (21:47 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Sat, 9 Nov 2013 02:47:44 +0000 (21:47 -0500)
src/mlp_train.c

index 2e9568b..769f503 100644 (file)
@@ -121,8 +121,6 @@ double compute_gradient(MLPTrain *net, float *inputs, float *outputs, int nbSamp
        double netOut[MAX_NEURONS];
        double error[MAX_NEURONS];
 
-       for (i=0;i<outDim;i++)
-          error_rate[i] = 0;
        topo = net->topo;
        inDim = net->topo[0];
        hiddenDim = net->topo[1];
@@ -135,6 +133,8 @@ double compute_gradient(MLPTrain *net, float *inputs, float *outputs, int nbSamp
        memset(W1_grad, 0, W1_size*sizeof(double));
        for (i=0;i<outDim;i++)
                netOut[i] = outputs[i];
+       for (i=0;i<outDim;i++)
+          error_rate[i] = 0;
        for (s=0;s<nbSamples;s++)
        {
                float *in, *out;