Overcoming 'catastrophic forgetting': Algorithm inspired by brain allows neural networks to retain knowledge