Deep representations with learned constraints