Thank you for your kind reply. Yes, weight is a learnable parameter, and use tanh(weight) to limit the weight range.
Apart from with torch.no_grad, what is the difference between putting self.conv1[0].weight[:] = torch.tanh(self.conv1[0].weight[:]) before def forward(self, x): and inside def forward(self, x):.
Thank you again for your time.
Best regards.