Reset the parameters of a model - PyTorch Forums
discuss.pytorch.org › t › reset-the-parameters-of-aNov 17, 2018 · However, if you just want to train from scratch using a new model, you could just instantiate a new model, which will reset all parameters by default or use a method to initialize your parameters: def weight_init(m): if isinstance(m, nn.Conv2d) or isinstance(m, nn.ConvTranspose2d): nn.init.xavier_uniform_(m.weight, gain=nn.init.calculate_gain('relu')) nn.init.zeros_(m.bias)model.apply(weight_init)
How to re-set alll parameters in a network - PyTorch Forums
discuss.pytorch.org › t › how-to-re-set-alllJul 06, 2018 · How to re-set alll parameters in a network. How to re-set the weights for the entire network, using the original pytorch weight initialization. You could create a weight_reset function similar to weight_init and reset the weigths: def weight_reset (m): if isinstance (m, nn.Conv2d) or isinstance (m, nn.Linear): m.reset_parameters () model = = nn.Sequential ( nn.Conv2d (3, 6, 3, 1, 1), nn.ReLU (), nn.Linear (20, 3) ) model.apply (weight_reset)