解决TypeError: __init__() got an unexpected keyword argument ‘iter‘的问题

1.在运行word2vec_train自定义函数中出错
TypeError: init() got an unexpected keyword argument ‘size’
解决TypeError: __init__() got an unexpected keyword argument ‘iter‘的问题_第1张图片
2.查找资料再word2vec源码里面

def __init__(
        self, sentences=None, corpus_file=None, vector_size=100, alpha=0.025, window=5, min_count=5,
        max_vocab_size=None, sample=1e-3, seed=1, workers=3, min_alpha=0.0001,
        sg=0, hs=0, negative=5, ns_exponent=0.75, cbow_mean=1, hashfxn=hash, epochs=5, null_word=0,
        trim_rule=None, sorted_vocab=1, batch_words=MAX_WORDS_IN_BATCH, compute_loss=False, callbacks=(),
        comment=None, max_final_vocab=None,
    ):

3.解决方案:

size=vocab_dim

改为

vector_size=vocab_dim

4.在运行word2vec_train自定义函数中出错

TypeError: init() got an unexpected keyword argument ‘iter’
解决TypeError: __init__() got an unexpected keyword argument ‘iter‘的问题_第2张图片
5.解决方案
解决TypeError: __init__() got an unexpected keyword argument ‘iter‘的问题_第3张图片

iter=n_iterations

改为
解决TypeError: __init__() got an unexpected keyword argument ‘iter‘的问题_第4张图片

epochs=n_iterations

加更:
gensim库的版本号不一样则参数不一样
gensim==3.0.0:

size=vocab_dim,
iter=n_iterations

gensim==4.0.0:

vector_size=vocab_dim,
epochs=n_iterations

你可能感兴趣的:(python,深度学习,batch)