IP Library Granted Patent US 12,288,393
Granted Patent B2
US 12,288,393 · App. 17/798,969 · Granted Apr 29, 2025

Classifying out-of-distribution data using a contrastive loss

Inventors: Rudy Bunel (London, GB); Jim Huibrecht Winkens (London, GB); Abhijit Guha Roy (London, GB); Olaf Ronneberger (London, GB); Seyed Mohammadali Eslami (London, GB); Ali Taylan Cemgil (London, GB); Simon Kohl (London, GB)
Assignee: Google LLC
G06V10/82G06T7/0012G06T2207/20081G06V2201/03
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,288,393
App. No.
17/798,969
Granted
Apr 29, 2025
Kind
B2
Abstract

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for training a neural network to (i) generate accurate network outputs for a machine learning task and (ii) generate intermediate outputs that can be used to reliably classify out-of-distribution inputs. In one aspect, a method comprises: training the neural network using supervised and contrastive losses, comprising repeatedly performing operations including: obtaining first and second network inputs; processing each network input using the neural network to generate its respective network input embedding; processing the first network input using the neural network to generate a network output; and adjusting the network parameter values using supervised and contrastive loss gradients, wherein: the supervised loss is based on: (i) the network output, and (ii) a corresponding target network output; and the contrastive loss is based on at least: (i) the first network input embedding, and (ii) the second network input embedding.

Claims (65)

1. A method performed by one or more computers, the method comprising:

training a neural network to jointly optimize a supervised loss and a contrastive loss, comprising:

obtaining a first network input and a second network input;

processing the first network input using a neural network to generate: (i) an embedding of the first network input as an intermediate output of the neural network, and (ii) a prediction output for the first network input;

processing the second network input using the neural network to generate at least an embedding of the second network input as an intermediate output of the neural network; and

adjusting current values of the network parameters using gradients of the supervised loss and the contrastive loss, wherein:

the supervised loss is based on an error between: (i) the prediction output for the first network output, and (ii) a target output for the first network input; and

the contrastive loss is based on at least: (i) the embedding of the first network input, and (ii) the embedding of the second network input; and

wherein after training, the neural network is used to perform out-of-distribution detection by performing operations comprising:

obtaining a test network input;

processing the test network input using the neural network to generate: (i) an embedding of the test network input as an intermediate output of the trained neural network, and (ii) a prediction output for the test network input;

classifying the test network input as being an out-of-distribution network input based on a likelihood of the embedding of the test network input under a probability distribution over a space of possible embeddings; and

in response, blocking the prediction output for the test network input from downstream processing.

2. The method of claim 1 , wherein adjusting current values of the network parameters using gradients of the contrastive loss comprises:

determining the contrastive loss based at least in part on a similarity between the embedding of the first network input and the embedding of the second network input.

3. The method of claim 2 , wherein the first network input and the second network input both correspond to a same training network input, and adjusting current values of the network parameters using gradients of the contrastive loss comprises:

adjusting the current values of the network parameters using the gradients to encourage the neural network to generate respective embeddings of the first network input and the second network input that are more similar.

4. The method of claim 3 , wherein obtaining the first network input and the second network input comprises:

sampling a first transformation from a set of possible transformations and applying the first transformation to the same training network input to generate the first network input; and

sampling a second transformation from the set of possible transformations and applying the second transformation to the same training network input to generate the second network input.

5. The method of claim 2 , wherein the first network input and the second network input do not correspond to a same training network input, and adjusting current values of the network parameters using gradients of the contrastive loss comprises:

adjusting the current values of the network parameters using the gradients to encourage the neural network to generate respective embeddings of the first network input and the second network input that are less similar.

6. The method of claim 2 , wherein determining the contrastive loss based at least in part on a similarity between the embedding of the first network input and the embedding of the second network input comprises:

processing the embedding of the first network input using a projection function to generate a projected embedding of the first network input;

processing the embedding of the second network input using the projection function to generate a projected embedding of the second network input; and

determining the similarity between the embedding of the first network input and the embedding of the second network input based on a similarity measure between: (i) the projected embedding of the first network input, and (ii) the projected embedding of the second network input.

7. The method of claim 6 , wherein the similarity measure is a cosine similarity measure.

8. The method of claim 6 , wherein the projection function comprises a projection neural network having a plurality of projection neural network parameters.

9. The method of claim 8 , further comprising adjusting current values of the projection neural network parameters using the gradients of the contrastive loss.

10. The method of claim 6 , wherein the projected embedding of the first network input has a lower dimensionality than the first network input, and the projected embedding of the second network input has a lower dimensionality than the second network input.

11. The method of claim 1 , wherein the probability distribution over the space of possible embeddings is determined based on a collection of embeddings in the space of possible embeddings, wherein each embedding is generated by processing an in-distribution network input using the trained neural network to generate an embedding of the in-distribution network input as an intermediate output of the trained neural network.

12. The method of claim 1 , wherein the machine learning task comprises a classification task, and the neural network is configured to process a network input to generate a network output corresponding to the network input that comprises a respective score for each of a plurality of classes.

13. The method of claim 12 , wherein the neural network is configured to process a network input that comprises an image or an audio signal.

14. The method of claim 13 , wherein the image is a medical image of a patient.

15. The method of claim 14 , wherein each class corresponds to a respective medical condition and the respective score for each class represents a predicted likelihood that the patient has the corresponding medical condition.

16. A system comprising:

one or more computers; and

one or more storage devices communicatively coupled to the one or more computers, wherein the one or more storage devices store instructions that, when executed by the one or more computers, cause the one or more computers to perform operations comprising:

training a neural network to jointly optimize a supervised loss and a contrastive loss, comprising:

obtaining a first network input and a second network input;

processing the first network input using a neural network to generate: (i) an embedding of the first network input as an intermediate output of the neural network, and (ii) a prediction output for the first network input;

processing the second network input using the neural network to generate at least an embedding of the second network input as an intermediate output of the neural network; and

adjusting current values of the network parameters using gradients of the supervised loss and the contrastive loss, wherein:

the supervised loss is based on an error between: (i) the prediction output for to the first network output, and (ii) a target output for the first network input; and

the contrastive loss is based on at least: (i) the embedding of the first network input, and (ii) the embedding of the second network input; and

wherein after training, the neural network is used to perform out-of-distribution detection by performing operations comprising:

obtaining a test network input;

processing the test network input using the neural network to generate: (i) an embedding of the test network input as an intermediate output of the trained neural network, and (ii) a prediction output for the test network input;

classifying the test network input as being an out-of-distribution network input based on a likelihood of the embedding of the test network input under a probability distribution over a space of possible embeddings; and

in response, blocking the prediction output for the test network input from downstream processing.

17. One or more non-transitory computer storage media storing instructions that when executed by one or more computers cause the one or more computers to perform operations comprising:

training a neural network to jointly optimize a supervised loss and a contrastive loss, comprising:

obtaining a first network input and a second network input;

processing the first network input using a neural network to generate: (i) an embedding of the first network input as an intermediate output of the neural network, and (ii) a prediction output for the first network input;

processing the second network input using the neural network to generate at least an embedding of the second network input as an intermediate output of the neural network; and

adjusting current values of the network parameters using gradients of the supervised loss and the contrastive loss, wherein:

the supervised loss is based on an error between: (i) the prediction output for the first network output, and (ii) a target output for the first network input; and

the contrastive loss is based on at least: (i) the embedding of the first network input, and (ii) the embedding of the second network input; and

wherein after training, the neural network is used to perform out-of-distribution detection by performing operations comprising:

obtaining a test network input;

processing the test network input using the neural network to generate: (i) an embedding of the test network input as an intermediate output of the trained neural network, and ii) a prediction output for the test network input;

classifying the test network input as being an out-of-distribution network input based on a likelihood of the embedding of the test network input under a probability distribution over a space of possible embeddings; and

in response, blocking the prediction output for the test network input from downstream processing.

18. The non-transitory computer storage media of claim 17 , wherein adjusting current values of the network parameters using gradients of the contrastive loss comprises:

determining the contrastive loss based at least in part on a similarity between the embedding of the first network input and the embedding of the second network input.

Assignments (2)
CORRECTIVE ASSIGNMENT TO CORRECT THE THE EXECUTION DATES FOR ALL OF THE INVENTORS. PREVIOUSLY RECORDED AT REEL: 060820 FRAME: 0466. ASSIGNOR(S) HEREBY CONFIRMS THE ASSIGNMENT. Recorded Aug 18, 2022
From: BUNEL, RUDY; WINKENS, JIM HUIBRECHT; GUHA ROY, ABHIJIT; RONNEBERGER, OLAF; ESLAMI, SEYED MOHAMMADALI; CEMGIL, ALI TAYLAN; KOHL, SIMON
To: GOOGLE LLC
Reel/Frame 061204/0862 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 16, 2022
From: BUNEL, RUDY; WINKENS, JIM HUIBRECHT; GUHA ROY, ABHIJIT; RONNEBERGER, OLAF; ESLAMI, SEYED MOHAMMADALI; CEMGIL, ALI TAYLAN; KOHL, SIMON
To: GOOGLE LLC
Reel/Frame 060820/0466 →
Continuity (2)
Provisional Application 63035578 · Jun 5, 2020
Related Publication 20230107505A1 · Apr 6, 2023
References Cited (48)
US 20210125006A1 · Seo · 2021 [cited by examiner]
US 20210141995A1 · Lundgaard · 2021 [cited by examiner]
US 20210287084A1 · Sivakumar · 2021 [cited by examiner]
US 20210353203A1 · Burman · 2021 [cited by examiner]
US 20210365771A1 · Speakman · 2021 [cited by examiner]
CN 110651280 · 2020 [cited by examiner]
CN 110969191 · 2020 [cited by examiner]
Machine translation for CN 110969191 (Year: 2020). [cited by examiner]
Machine translation for 110651280 (Year: 2020). [cited by examiner]
Bachman et al., “Learning representations by maximizing mutual information across views,” Advances in Neural Information Processing Systems, Dec. 2019, 11 pages. [cited by applicant]
Blundell et al., “Weight uncertainty in neural networks,” arXiv, May 21, 2015, 10 pages. [cited by applicant]
Chen et al., “A simple framework for contrastive learning of visual representations,” arXiv, Feb. 13, 2020, 17 pages. [cited by applicant]
Chen et al., “A variational dirichlet framework for out-of-distribution detection,” arXiv, Apr. 20, 2019, 8 pages. [cited by applicant]
Choi et al., “WAIC, but Why? Generative Ensembles for Robust Anomaly Detection,” arXiv, May 23, 2019, 11 pages. [cited by applicant]
De Vries et al., “Learning Confidence for Out-of-Distribution Detection in Neural Networks,” arXiv, Feb. 13, 2018, 12 pages. [cited by applicant]
Gal et al., “Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning,” Proceedings of The 33rd International Conference on Machine Learning, 2016, 10 pages. [cited by applicant]
He et al., “Deep residual learning for image recognition,” Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, Jun. 2016, pp. 770-778. [cited by applicant]
He et al., “Momentum contrast for unsupervised visual representation learning,” arXiv, Mar. 23, 2020, 12 pages. [cited by applicant]
Henaff et al., “Data-efficient image recognition with contrastive predictive coding,” Proceedings of the 37th International Conference on Machine Learning, 2020, 11 pages. [cited by applicant]
Hendrycks et al., “A baseline for detecting misclassified and out-of-distribution examples in neural networks,” arXiv, Oct. 3, 2018, 12 pages. [cited by applicant]
Hendrycks et al., “Deep anomaly detection with outlier exposure,” arXiv, Oct. 3, 2018, 12 pages. [cited by applicant]
Hendrycks et al., “Using self-supervised learning can improve model robustness and uncertainty,” Advances in Neural Information Processing Systems, Dec. 2019, 12 pages. [cited by applicant]
International Preliminary Report on Patentability in International Appln. No. PCT/US2021/035842, mailed on Dec. 15, 2022, 8 pages. [cited by applicant]
International Search Report and Written Opinion in International Appln. No. PCT/US2021/035842, mailed on Sep. 21, 2021, 14 pages. [cited by applicant]
Kamoi et al., “Why is the mahalanobis distance effective for anomaly detection?” arXiv, Apr. 30, 2020, 23 pages. [cited by applicant]
Krizhevsky, “Learning multiple layers of features from tiny images,” Technical report, Apr. 8, 2009, 60 pages. [cited by applicant]
Lakshminarayanan et al., “Simple and scalable predictive uncertainty estimation using deep ensembles,” Advances in neural information processing systems, Dec. 2017, 12 pages. [cited by applicant]
Lee et al., “A simple unified framework for detecting out-ofdistribution samples and adversarial attacks,” Advances in Neural Information Processing Systems, Dec. 2018, 11 pages. [cited by applicant]
Lee et al., “Training confidence-calibrated classifiers for detecting out-of-distribution samples,” arXiv, Feb. 23, 2018, 16 pages. [cited by applicant]
Liang et al., “Enhancing the reliability of out-of-distribution image detection in neural networks,” arXiv, Aug. 30, 2020, 15 pages. [cited by applicant]
Malinin et al., “Predictive uncertainty estimation via prior networks,” Advances in Neural Information Processing Systems, Dec. 2018, 12 pages. [cited by applicant]
Masana et al., “Metric learning for novelty and anomaly detection,” arXiv, Aug. 16, 2018, 17 pages. [cited by applicant]
Mohseni et al., “Self-supervised learning for generalizable out-of-distribution detection,” Proceedings of the AAAI Conference on Artificial Intelligence, Apr. 3, 2020, 8 pages. [cited by applicant]
Muller et al., “When does label smoothing help?” Advances in Neural Information Processing Systems, Dec. 2019, 10 pages. [cited by applicant]
Nalisnick et al., Do deep generative models know what they don't know?, arXiv, Feb. 24, 2019, 19 pages. [cited by applicant]
Nalisnick et al., “Hybrid models with deep and invertible features,” arXiv, May 29, 2019, 11 pages. [cited by applicant]
Netzer et al., “Reading digits in natural images with unsupervised feature learning,” Advances in Neural Information Processing Systems, Dec. 2011, 9 pages. [cited by applicant]
Nguyen et al., “Deep neural networks are easily fooled: High confidence predictions for unrecognizable images,” Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, Jun. 2015, pp. 427-436. [cited by applicant]
Recht et al., “Do ImageNet Classifiers Generalize to ImageNet?” Proceedings of the 36th International Conference on Machine Learning, Jun. 2019, 12 pages. [cited by applicant]
Ren et al., “Likelihood ratios for out-of-distribution detection,” Advances in Neural Information Processing Systems, Dec. 2019, 12 pages. [cited by applicant]
Sastry et al., “Detecting out-of-distribution examples with gram matrices,” Proceedings of the 37th International Conference on Machine Learning, 2020, 11 pages. [cited by applicant]
Scheirer et al., “Toward open set recognition,” IEEE Transactions on Pattern Analysis and Machine Intelligence, Nov. 29, 2012, 35(7):1757-1772. [cited by applicant]
Shalev et al., “Out-of-distribution detection using multiple semantic label representations,” Advances in Neural Information Processing Systems, Dec. 2018, 11 pages. [cited by applicant]
Vyas et al., “Out-of-distribution detection using an ensemble of self supervised leave-out classifiers,” Proceedings of the European Conference on Computer Vision, 2018, pp. 550-564. [cited by applicant]
Zhang et al., “COVID-19 Screening on Chest X-ray images using deep learning based anomaly detection,” arXiv, Mar. 27, 2020, 6 pages. [cited by applicant]
Zhang et al., “Hybrid models for open set recognition,” arXiv, Aug. 4, 2020, 16 pages. [cited by applicant]
Zisselman et al., “Deep residual flow for novelty detection,” Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Jun. 2020, pp. 13994-14003. [cited by applicant]
Office Action in European Appln. No. 21735555.1, mailed on Feb. 20, 2025, 5 pages. [cited by applicant]