无法使用fastai的pretrained_model = URLs.WT103

时间:2019-07-28 10:37:51

标签: python-3.x fast-ai

尝试使用fastai的language_model_learner:

learn = language_model_learner(data_lm, pretrained_model=URLs.WT103, drop_mult=0.7)

错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-811dec5cedeb> in <module>
----> 1 learn = language_model_learner(data_lm, 
pretrained_model=URLs.WT103, drop_mult=0.7)

AttributeError: type object 'URLs' has no attribute 'WT103'

3 个答案:

答案 0 :(得分:3)

今天,当我尝试微调预训练的语言模型时,我遇到了类似的问题。看来他们已经更改了数据链接,可以使用 URLs.WT103_FWD URLs.WT103_BWD 代替使用 URLs.WT103

还将'arch'参数的值添加为AWD_LSTM并预先训练为True,默认情况下将使用预先训练的WT103_FWD的权重​​。

答案 1 :(得分:1)

尝试删除pretrained_model的参数,例如 learn = language_model_learner(data_lm, arch = AWD_LSTM, pretrained = True, drop_mult=0.7) 对我来说很好。

答案 2 :(得分:0)

似乎API已更改。试试

learn = language_model_learner(data_lm, AWD_LSTM, drop_mult=0.7)

根据official guideline中的建议。

有关language_model_learner()的更多详细信息,请参见here