Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,报这个错是什么原因 #47

Open
Angelucky opened this issue Nov 29, 2024 · 4 comments
Open

你好,报这个错是什么原因 #47

Angelucky opened this issue Nov 29, 2024 · 4 comments

Comments

@Angelucky
Copy link

Traceback (most recent call last):
File "/mnt/workspace/BERT-BILSTM-CRF/main.py", line 190, in
main(data_name)
File "/mnt/workspace/BERT-BILSTM-CRF/main.py", line 182, in main
train.train()
File "/mnt/workspace/BERT-BILSTM-CRF/main.py", line 45, in train
for step, batch_data in enumerate(self.train_loader):
File "/mnt/workspace/BERT-BILSTM-CRF/env/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 631, in next
data = self._next_data()
File "/mnt/workspace/BERT-BILSTM-CRF/env/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 675, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/mnt/workspace/BERT-BILSTM-CRF/env/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/mnt/workspace/BERT-BILSTM-CRF/env/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/mnt/workspace/BERT-BILSTM-CRF/data_loader.py", line 28, in getitem
labels = [self.label2id[label] for label in labels]
File "/mnt/workspace/BERT-BILSTM-CRF/data_loader.py", line 28, in
labels = [self.label2id[label] for label in labels]
KeyError: ''

@Angelucky
Copy link
Author

是不是训练数据当中某一条数据里面没有标签,全是O的问题

@Angelucky
Copy link
Author

数据格式这么可以吗
{"id": "2840", "text": ["山", "西", "省", "残", "联", "理", "事", "长", "苏", "高", "文", "说", ":", "“", "扶", "持", "残", "疾", "人", "解", "决", "温", "饱", ",", "不", "是", "残", "联", "一", "家", "的", "事", "情", ",", "而", "是", "由", "全", "社", "会", "共", "挑", "的", "担", "子", "。"], "labels": ["B-ORG", "I-ORG", "I-ORG", "I-ORG", "I-ORG", "O", "O", "O", "B-PER", "I-PER", "I-PER", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "B-ORG", "I-ORG", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O"]}

@taishan1994
Copy link
Owner

可以的

@Angelucky
Copy link
Author

解决了,数据的问题,里面有空字符串""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants