Learning in neural networks by eliminating frustrated bonds