torch.nn.utils.skip_init
- torch.nn.utils.skip_init(module_cls, *args, **kwargs)
Given a module class object and args / kwargs, instantiate the module without initializing parameters / buffers.
This can be useful if initialization is slow or if custom initialization will be performed, making the default initialization unnecessary. There are some caveats to this, due to the way this function is implemented:
1. The module must accept a device arg in its constructor that is passed to any parameters or buffers created during construction.
2. The module must not perform any computation on parameters in its constructor except initialization (i.e. functions from ).