level 3
◎御坂雷丘◎
楼主
def predict(text, sent_attn_model, text_field, label_field, cuda_flag):
这里text_field和label_field都是用torchtext.data.Field创建的对象,但是在调用text_field的preprocess方法和vocab时报错了,但报的是module 'torch' has no attribute,而不是torchtext相关的报错。
text = [[text_field.vocab.stoi[x] for x in text]]
AttributeError: module 'torch' has no attribute 'vocab'
以及
text = text_field.preprocess(text)
AttributeError: module 'torch' has no attribute 'preprocess'
2023年04月05日 07点04分
1
这里text_field和label_field都是用torchtext.data.Field创建的对象,但是在调用text_field的preprocess方法和vocab时报错了,但报的是module 'torch' has no attribute,而不是torchtext相关的报错。
text = [[text_field.vocab.stoi[x] for x in text]]
AttributeError: module 'torch' has no attribute 'vocab'
以及
text = text_field.preprocess(text)
AttributeError: module 'torch' has no attribute 'preprocess'
