turn off or ignore neurons in pytorch in neural networks

Viewed 897

I want to build a feed forward-neural network and train it (to overfitt) on a small portion of the input features. For this I used dropout regularization as it follows the logic on training on small portion and then test model on the whole features (Turning off during training and turn on test).

But since I am interested on overfitting, I don't think dropout is a good solution for me. So how can I turn off some input nodes during training in the same way as used in Dropout regularization, but this time I don't want randomly turn them off, but chose which featured will be ignored during training ?

1 Answers

You can do:

for param in model.parameters():
  param.requires_grad = False

to turn off layers in the model

Related