gpt4 book ai didi

machine-learning - Fastai学习器未加载

转载 作者:行者123 更新时间:2023-11-30 08:24:45 26 4
gpt4 key购买 nike

所以我尝试使用以下方式加载模型:

learn = create_cnn(data, models.resnet50, lin_ftrs=[2048], metrics=accuracy) 
learn.clip_grad();
learn.load(f'{name}-stage-2.1')

但我收到以下错误

RuntimeError: Error(s) in loading state_dict for Sequential:
size mismatch for 1.8.weight: copying a param with shape torch.Size([5004, 2048]) from checkpoint, the shape in current model is torch.Size([4542, 2048]).
size mismatch for 1.8.bias: copying a param with shape torch.Size([5004]) from checkpoint, the shape in current model is torch.Size([4542]).

唯一不同的是我添加了 stage-2.1 中不存在的随机验证拆分。模型,当我删除拆分并且没有将验证设置为 stage-2.1 时受过训练一切顺利。

发生什么事了?

最佳答案

使用cnn_learner方法及最新Pytorch最新FastAI 。有一个breaking change和不连续性,所以你现在受苦了。

fastai网站有很多例子,例如this one

learn = cnn_learner(data, models.resnet50, metrics=accuracy)

关于machine-learning - Fastai学习器未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54914106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com