Set learnable parameters to random values

Is it possible to set the learnable parameters of a model to random values? Thanks in advance.

Yes, usually parameters are initialized with a specific initialization method to random values.
E.g. the parameters of nn.Linear are reset in these lines of code.

If you want to use an init method, have a look at torch.nn.init.

2 Likes