Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference for Deep Ensemble #7

Open
psteinb opened this issue Jan 16, 2024 · 1 comment
Open

Inference for Deep Ensemble #7

psteinb opened this issue Jan 16, 2024 · 1 comment

Comments

@psteinb
Copy link

psteinb commented Jan 16, 2024

Hi @mvaldenegro -
I returned to this repo to prepare some examples for a lecture series I am giving. When I went through your code, I stumbled to this line:
https://github.com/mvaldenegro/keras-uncertainty/blob/42f50a36c70003b16b7f343002766708ad2a289a/keras_uncertainty/models/DeepEnsembleClassifier.py#L219C1-L220C73

predictions = np.concatenate(predictions)
mean_pred = np.mean(predictions, axis=0)
mean_pred = mean_pred / np.sum(mean_pred, axis=1, keepdims=True)

according to the DeepEnsemble paper, one should average the predicted probabilities in the classification case. I guess, that is the line which instantiates the variable mean_pred. But I am a bit lost, why you "normalize" this again in the last line of the excerpt above. Can you comment please?

@mvaldenegro
Copy link
Owner

Hey @psteinb
Because sometimes you would get probabilities that sum to 0.99 or even 0.98, due to numerical error and rounding, this way you make sure probabilities sum to 1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants