An indication of semantic relationships among classes is obtained. A neural network whose loss function is based at least partly on the semantic relationships is trained. The trained neural network is used to identify one or more classes to which an input observation belongs.