A new mechanical approach to handle generalized Hopfield neural networks