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

include a mask for ece calculation #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ekellbuch
Copy link

This code includes a sample_weight variable to mask the logits used to calculate the ECE.

sample_weight = tf.reshape(sample_weight, [-1])

probabilities = tf.boolean_mask(probabilities, sample_weight)
labels = tf.boolean_mask(labels, sample_weight)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this further, if we added a sample_weight parameter to this method, to follow the convention in tf.keras.metrics.Metric, we'd need sample_weight to be a (broadcastable) tensor of continuous values that are multiplied with the samples in some manner. It's a simple weighted average for Accuracy, and more involved for something like AUC. For ECE, we'd need to think more about how to add a general sample_weight, i.e., how to compute ECE with continuously-weighted samples. Binary masking is a subset of the cases that should be handled to follow the Keras API.

For the case of masking out a subset of samples, I'd suggest that we move that logic to the calling site, so in the training code that calls this metric rather than inside the metric.

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

Successfully merging this pull request may close these issues.

2 participants