What's the default initialization methods for layers?

For PyTorch 1.0, most layers are initialized using Kaiming Uniform method. Example layers include Linear, Conv2d, RNN etc. If you are using other layers, you should look up that layer on this doc. If it says weights are initialized using U(...) then its Kaiming Uniform method. This is in line with PyTorch’s philosophy of “reasonable defaults”.

If you want to override default initialization then see this answer.

12 Likes

A gentle remark, maybe it makes sense to add a reference to the default initialization modules implementation, in torch, on the documentation page of say Conv1d and other modules. Probably would make life much simpler. :stuck_out_tongue:

It is already mentioned in the variables section that explain what are the parameter shape and how they are initialized: Conv1d — PyTorch master documentation
Is that the information you were looking for? Or something else?

I mean the default initialization is done using He normal method. So it makes sense to add a hyper link to the specific section of the document present at torch.nn.init — PyTorch 1.9.0 documentation. This can be added at
vars

This would make life easier since one could just jump to the hyperlink to check the function signature as well as implementation details.

Yes sure.
That doc preceedes the existence of nn.init IIRC so that would be the reason.
Can you can open an issue on github for that request?

Sure thing. I will set it up :+1: