Alleviating catastrophic forgetting using context-dependent gating and synaptic stabilization