Also you it does not seem like you are removing any connections so the name of the function and the title of the topic is confusing. You are freezing connections where as removing would be understood as setting the weights to zero not the gradients.