Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for training an encoder neural network having multiple encoder neural network parameters. The encoder neural network is configured to process a biometric data sample in accordance with current values of encoder neural network parameters to generate as output an embedded representation of the biometric data sample. The embedded representation includes: (i) an inter-class embedded representation, and (ii) an intra-class embedded representation that is different than the inter-class embedded representation.