Dreaming neural networks: Forgetting spurious memories and reinforcing pure ones