A relativistic extension of Hopfield neural networks via the mechanical analogy