当我在构建用于自动生成源代码注释的深度学习模型时,遇到了上述错误。我使用了变换器模型来创建模型。有人能给我提供一个解决方案吗?
回答:
看起来你在使用transformers模块。根据文档,参数的提供顺序是:
def __init__( self, vocab_size=267735, cutoffs=[20000, 40000, 200000], d_model=1024, d_embed=1024, n_head=16, d_head=64, d_inner=4096, div_val=4, pre_lnorm=False, n_layer=18, mem_len=1600, clamp_len=1000, same_length=True, proj_share_all_but_first=True, attn_type=0, sample_softmax=-1, adaptive=True, dropout=0.1, dropatt=0.0, untie_r=True, init="normal", init_range=0.01, proj_init_std=0.01, init_std=0.02, layer_norm_epsilon=1e-5, eos_token_id=0, **kwargs )
由于你没有向构造函数提供正确的参数名称,它将n_x_vocab
关联到了vocab_size
,将n_y_vocab
关联到了cutoffs
。因此,所需的参数n_head
、d_inner
、n_layer
和d_head
被视为缺失。
一旦你以适当的顺序提供参数和/或像你在d_model = 256
中那样明确命名参数,这个错误应该就能得到解决。