(self, module)
Initialize the weights.
Initialize the weights.
Initialize the weights .
def _init_weights(self, module):
        """ Initialize the weights.
        """
        if isinstance(module, (nn.Linear, nn.Embedding, Conv1D)):
            # Slightly different from the TF version which uses truncated_normal for initialization
            # cf https://github.com/pytorch/pytorch/pull/5617
            module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
            if isinstance(module, (nn.Linear, Conv1D)) and module.bias is not None:
                module.bias.data.zero_()
        elif isinstance(module, nn.LayerNorm):
            module.bias.data.zero_()
            module.weight.data.fill_(1.0)
def _init_weights ( self , module ) : if isinstance ( module , ( nn . Linear , nn . Embedding , Conv1D ) ) : # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 module . weight . data . normal_ ( mean = 0.0 , std = self . config . initializer_range ) if isinstance ( module , ( nn . Linear , Conv1D ) ) and module . bias is not None : module . bias . data . zero_ ( ) elif isinstance ( module , nn . LayerNorm ) : module . bias . data . zero_ ( ) module . weight . data . fill_ ( 1.0 )