Facial expression recognition aims to classify facial expression as one of seven basic emotions including 'neutral'. This is a difficult problem due to the complexity and subtlety of human facial expressions, but the technique is needed in important applications such as social interaction research. Deep learning methods have achieved state-of-the-art performance in many tasks including face recognition and person re-identification. Here we present a deep learning method termed Deep Neural Networks with Relativity Learning (DNNRL), which directly learns a mapping from original images to a Euclidean space, where relative distances correspond to a measure of facial expression similarity. DNNRL updates the model parameters according to sample importance. This strategy results in an adjustable and robust model. Experiments on two representative facial expression datasets (FER-2013 and SFEW 2.0) are performed to demonstrate the robustness and effectiveness of DNNRL.