# Deep model ensemble giving different results

I am making an ensemble of deep models for solving a classification problem. The initial weights follow the default distribution of keras layers. Each time I run the model(train the 'n' models, make predictions and then get their mode), I get a different result. What could be the possible reasons(rather errors) for this? And how shall I handle them?

• What do you mean by different result? In what sense are they different? – matthiaw91 Oct 23 at 12:42
• The F1 score, precision, recall etc vary on the predictions. – yamini goel Oct 23 at 14:48

Getting varying results at the level of F1 score is possible but should be high, as your are essentially taking the average over many values (assuming a reasonably sized dataset).

There are however many sources of random behaviour that could be creeping in. From most obvious to most obscure:

1. Are the definitions and parameters of each of your models identical each time?
2. Do you use the same train/validation/test splits for each session?
3. Are your training hyper-parameters (number of epochs, learning rate, early stopping) the same each time?
4. Do you set the random seed in Numpy/Keras/Tensorflow?
5. Did you set any Nvidia CUDA flags for determinism?

Regarding the final point, GPU determinism - this is a very new thing in the context of deep learning and many people believed it was impossible, but there is good progress being made. Check out these video/slides from Nvidia GTC conference this year.

These are really just the components of each individual building block i.e. each deep model. You could also introduce random behaviour perhaps in the way you chain these models together to create your ensemble.

• I understand your points but don't know if fixing seed values would be a good idea. Point 1,2 and 3 are not my cases. Now in such a case what shall be the right choice in terms of reporting the results? Fixing seeds? – yamini goel Oct 24 at 0:43
• I would usually report some results with a level of confidence. Fixing seeds will be necessary if you want exact result every time, otherwise most libraries/algorithms will introduce some random choice somewhere - a simple example is shuffling the data or weight initialisation. – n1k31t4 Oct 24 at 13:22
• Just an afterthought @n1k31t4 if I said the seed values, will this not mean that all models in the ensemble would have same initial weights i.e making them identical in my case? – yamini goel Oct 29 at 15:29