简体   繁体   中英

turn off or ignore neurons in pytorch in neural networks

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?

You can do:

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

to turn off layers in the model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM