Hi rooters,
I have some questions about the normalization of MLP output. I use 0 and 1 represent background and signal respectively, following the instructions in mlpHiggs.C. The neural network training goes well but the output can be slightly less than 0 and greater than 1. I want to constrain the output to [0,1] so that the result looks nicer. So I put a “@” preceding the output neuron in the constructor of MLP and did the training again. Then I found the output was normalized to [-1,1] rather than [0,1]. My first question is why isn’t the output normalized to [0,1]? Is there any way I can control how the output should be normlized?
What confused me more happened when I exported the NN as a function for further use. I use the NN function as follows
nnsel *nn = nnsel();
Double_t nn_val = nn->value(0,in0,in1,in2,in3,in4,in5);
But the distribution of computed nn_val was observed between [0.5,1], which looked very strange. So I checked the codes of class nnsel. The implementation of output neuron is
double nnsel::neuron0x1b663a0() {
double input = input0x1b663a0();
return (input * 0.5)+0.5;
}
which I guess attempts to normalize output from [-1,1] to [0,1]. And the implementation of nnsel::value() is
double nnsel::value(int index,double in0,double in1,double in2,double in3,double in4,double in5) {
input0 = (in0 - 6.07017)/1.62633;
input1 = (in1 - 0)/1;
input2 = (in2 - 0)/1;
input3 = (in3 - 0)/1;
input4 = (in4 - 1292.67)/465.07;
input5 = (in5 - 3272.29)/941.692;
switch(index) {
case 0:
return ((neuron0x1b663a0()*0.5)+0.5);
default:
return 0.;
}
}
that does normalization again and finally the output is normalized from [0,1] to [0.5,1]. Maybe this is why nn_val was observed in [0.5,1].
If I simply modify
return ((neuron0x1b663a0()*0.5)+0.5);
to
return neuron0x1b663a0();
e.g. do not do the normalization a second time, then the output is between [0,1], just as I want. So I guess maybe there is some bug within TMultilayerPerceptron::Export() method when output normalization option is chosen(a ‘@’ is put preceded output neuron) if my above statement is right.
Any one can give me a hint how this is going on?