Exemple #1
0
    def reset_parameters(self):
        if self.add_position_embedding:
            nn.init.uniform_(self.embeddings.weight.data, - 1.0 / self.scale, 1.0 / self.scale)
        else:
            Init.embedding_init(self.embeddings.weight.data)

        self.embeddings.weight.data[self.padding_idx].fill_(0.0)
Exemple #2
0
    def reset_parameters(self):
        if self.add_position_embedding:
            nn.init.uniform(self.embeddings.weight, -1.0 / self.scale,
                            1.0 / self.scale)
        else:
            Init.embedding_init(self.embeddings.weight)

        with torch.no_grad():
            self.embeddings.weight[self.padding_idx].fill_(0.0)
Exemple #3
0
    def _reset_parameters(self):

        Init.embedding_init(self.proj.weight)