PyKeras application : how is the output computed?

Dear TMVA experts,

I have started playing around with the PyKeras method, but I could not yet understand how the NN output is computed (for application).

I believe the relevant function is Double_t MethodPyKeras::GetMvaValue(…) [0], which returns the single value : fOutput[TMVA::Types::kSignal];

This fOutput vector is said [1] to hold the probabilities for each target class (I have 2, signal and background).

  • Therefore, does return fOutput[TMVA::Types::kSignal]; mean that only 1 output neuron (<-> signal) is read, not the 2 I have in my model ?

  • What’s more I can not find where/how fOutput is filled. Does it simply contain the values held by each output neuron, or is some transformation applied (e.g. to ensure that the result are probabilities, etc.) ?

Thanks in advance, cheers,


@moneta knows who can help for the TMVA related questions

Dear experts,

any news on this ?



You are indeed correct that this is the relevant method.

For classification and multiclass classification the the values are read from the keras model and returned untransformed. In the binary classification setting, the TMVA model is to output only the signal class since the background class is a trivial transformation of this value.

If you want to get all outputs you can use the multiclass setting, then the function GetMulticlassValues is used.

The fOutput vector is filled through python, the python runtime is invoked to evaluate the keras model and make the predictions accessible to the c++ backend of TMVA.

Hope this helps!


Dear Kim,

it does, thank you very much.