Closed Qian-Hao closed 4 years ago
我在构建embedding的时候,通过nn.Embedding.from_pretrained()加入了自己预训练的embedding向量,请问怎样在模型训练过程中,保持embeding不会被改变?
模型的embeddings可以通过model.embeddings获得,然后用下面的方式把embeddings固定 requires_grad = False 具体看pytorch文档
https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/base.py#L23-L24
模型的embeddings可以通过model.embeddings获得,然后用下面的方式把embeddings固定 requires_grad = False 具体看pytorch文档 https://github.com/GitHub-HongweiZhang/prediction-flow/blob/master/prediction_flow/pytorch/base.py#L23-L24
谢谢
我在构建embedding的时候,通过nn.Embedding.from_pretrained()加入了自己预训练的embedding向量,请问怎样在模型训练过程中,保持embeding不会被改变?