Setting an output range for a MLP/DNN

Hi,

I am trying to train a MLP for a regression problem. The targets represent probabilities so I want to add this constraint in such a way that the evaluation only gives output values between 0 and 1. When I added the targets to the dataloader I set a minimum and maximum value but when randomly evaluating the trained MLP I kept getting values outside the 0-1 range. Is there another way to implement this constraint on the output? Would this also be possible for the DNN method? Thank you.

Kind regards,

Pim

@moneta or @kialbert , perhaps you can help here please?

Thank you so much,
Oksana.

Hi Pim!

Regression problems are often unbounded, as such TMVA does not try to constrain the range of the output function. Usually when talking about output probabilities, we are talking about a classification problem. So as a first step I’d recommend using "Analysistype=Classification" (or "Analysistype=Multiclass" if you have multiple outputs).

Let me know if that makes a difference for you. Otherwise, please expand a bit on what it is you want to do :slight_smile:

Cheers,
Kim

The goal is to parameterize a response matrix with nuisance parameters. Each matrix element R_{ij} gives the probability for an event initially found in truth histogram bin i to be found in reconstructed histogram bin j after smearing of the detector. I therefore generated truth histograms, smeared them with varying nuisance parameters to get the reconstructed histograms and calculated the response matrix elements from both histograms. I then use the initial nuisance parameter settings as input and the calculated response matrix elements as training output of the MLP.

I could do a multiclass if I just needed to map the truth to the reco bins but I need this trained MLP as input for a likelihood that I need to optimize w.r.t. these input NPs and some parameter of interest.

In the TMVA user guide I see that the activation function of a MLP output nodes are always linear. Isn’t it possible to set this to a sigmoid? This would make sure my output is always between 0 and 1 I think.

Ah, I think I see now, yes that should suffice. In MethodDNN this is possible by setting the activation of the last layer. In MLP, as you identify, the activation of the last layer is linear if the MSE loss function is used (if CE loss is used a sigmoid is used for the final layer).

The proper way would be to use MethodDNN as it allows more flexibility. If this is not possible to you then changing the loss function for MLP would be a possible option.

Cheers,
Kim

The changing of EstiimatorType to CE seems to work. However, when I changed the option string it did not change the xml output file. It did say that the EstimatorType was modified but the MSE string value remained. A bug?

Hi,

Great that it seems to be working for you. That does indeed seem like a bug; Thanks for reporting! You can follow the progress and resolution here: https://sft.its.cern.ch/jira/browse/ROOT-9811.

Cheers,
Kim

Great. Thanks for the advice!