649453932 / Chinese-Text-Classification-Pytorch

中文文本分类,TextCNN,TextRNN,FastText,TextRCNN,BiLSTM_Attention,DPCNN,Transformer,基于pytorch,开箱即用。
MIT License
5.29k stars 1.23k forks source link

网络结构中Model加载预训练词向量的疑问 #117

Open hgsw opened 6 months ago

hgsw commented 6 months ago

if config.embedding_pretrained is not None: self.embedding = nn.Embedding.from_pretrained(config.embedding_pretrained, freeze=False)

这里的freeze=Fasle 不是很理解,难道说词向量需要随着训练过程进行参数更新? torch 2.0.1 版本是True 描述为不参数网络参数更新? Args: embeddings (Tensor): FloatTensor containing weights for the Embedding. First dimension is being passed to Embedding as num_embeddings, second as embedding_dim. freeze (bool, optional): If True, the tensor does not get updated in the learning process. Equivalent to embedding.weight.requires_grad = False. Default: True