Text-Classification-Pytorch icon indicating copy to clipboard operation
Text-Classification-Pytorch copied to clipboard

TypeError: __init__() got an unexpected keyword argument 'tensor_type'

Open hsluoyz opened this issue 6 years ago • 2 comments

Running the main.py got the error:

C:\Python36\python.exe I:/github_repos/Text-Classification-Pytorch/main.py
Traceback (most recent call last):
  File "I:/github_repos/Text-Classification-Pytorch/main.py", line 11, in <module>
    TEXT, vocab_size, word_embeddings, train_iter, valid_iter, test_iter = load_data.load_dataset()
  File "I:\github_repos\Text-Classification-Pytorch\load_data.py", line 31, in load_dataset
    LABEL = data.LabelField(tensor_type=torch.FloatTensor)
  File "C:\Python36\lib\site-packages\torchtext\data\field.py", line 699, in __init__
    super(LabelField, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'tensor_type'

Process finished with exit code 1

hsluoyz avatar Jul 29 '19 05:07 hsluoyz

In load_data.py, remove the argument of LabelField in line 31: LABEL = data.LabelField()

fmehralian avatar Jul 29 '19 17:07 fmehralian

Running the main.py got the error:

module 'torchtext.data' has no attribute 'LabelField'. Could you help please, Thanks!

zhangxiaowbl avatar Apr 28 '21 10:04 zhangxiaowbl