davidrmiller / neural2d

Neural net optimized for 2D image data
MIT License
142 stars 69 forks source link

strange output, where Outputs: 0.409617 is considered Correct when expected value is 1 #35

Open mlako opened 7 years ago

mlako commented 7 years ago

Hi, I am trying to use neural2d in my thesis project on Voice Activity Detection. I have an input file with more than a million lines (13 input cepstral coefficients, one expected value Voice or Silence – 1/0). When training the net I noticed strange output, where Outputs: 0.409617 is considered Correct when expected value is 1. It seems to me strange. How the correct or wrong output is calculated. Thanks a lot

Pass #2600000: Outputs: 0.409617 Expected 1 Correct eta=7.00649e-43 Net error = 0.174276, running average = 0.0499153

Pass #2610000: Outputs: 0.912001 Expected 1 Correct eta=7.00649e-43 Net error = 0.00387187, running average = 0.0384916

Pass #2620000: Outputs: 0.533725 Expected 0 Wrong eta=7.00649e-43 Net error = 0.142431, running average = 0.0484277

davidrmiller commented 7 years ago

Hi @mlako, thanks for the report. That does look odd, but explicable. The determination and printout of "Correct" or "Wrong" is made in an optional block of code in neural2d-core.cpp at around line 2000 in the function Net::reportResults(). It doesn't affect how the neural net functions, and it's only meaningful if you're using your net as a classifier. You can ignore it or disable it.

That optional block of code is useful if you are using your net as a classifier with multiple output neurons where you train the net to output a positive (meaning true) signal on only one output neuron to indicate which class was recognized. In such a net, the code in question will find the output neuron with the highest value (the output neuron that is "most true") and print "Correct" iff that neuron's output and its target value are both greater than zero, indicating a correct classification.

Since you're not using your net as a classifier like that, you can safely disable that part of the report. It can be disabled in the source code by changing the "if (true)" to "if (false)" at the beginning of that block of code. There are some comments in the source code about how it works, but perhaps we should also have a command line option to make it easier to enable/disable that part of the report. Or perhaps we could automatically disable that code when there is only a single output neuron because you're clearly not using it as a classifier in that case.