Techniques are described herein for a method of obtaining a neural network trained using a first dataset to perform a first task. The method further comprises iteratively updating one or more weights of the neural network during a training phase. The training phase is used to teach the neural network to perform a second task using a second dataset. The one or more weights of the neural network are updated each iteration using a first projection matrix, a gradient of the one or more weights with respect to a loss function, and a second projection matrix. The method further comprises responsive to completion of the training phase, obtaining the neural network trained to perform the first task and the second task.