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

features 字典缺少 label ,keyerror问题 #52

Open
ZuoMM-f opened this issue Jan 16, 2025 · 5 comments
Open

features 字典缺少 label ,keyerror问题 #52

ZuoMM-f opened this issue Jan 16, 2025 · 5 comments

Comments

@ZuoMM-f
Copy link

ZuoMM-f commented Jan 16, 2025

在运行MKG任务bash scripts/pretrain_fb15k-237-image.sh脚本时候出现的缺少label的问题,请教这个问题的解决方法,wn18数据集也有这个问题,数据集下载的是作者提供的[GoogleDrive]
Epoch 0: 80%|███████████████████████████████████████████████████████████████████████████████████▉ | 935/1169 [48:27<12:07, 3.11s/it, loss=11.2, v_num=9, hits10=0.000, hits1=0.000]
Traceback (most recent call last): | 0/234 [00:00<?, ?it/s]
File "main.py", line 153, in
main()
File "main.py", line 135, in main
trainer.fit(lit_model, datamodule=data)
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 458, in fit
self._run(model)
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 756, in _run
self.dispatch()
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 797, in dispatch
self.accelerator.start_training(self)
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 96, in start_training
self.training_type_plugin.start_training(trainer)
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 144, in start_training
self._results = trainer.run_stage()
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 807, in run_stage
return self.run_train()
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 869, in run_train
self.train_loop.run_training_epoch()
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/training_loop.py", line 576, in run_training_epoch
self.trainer.run_evaluation(on_epoch=True)
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 949, in run_evaluation
for batch_idx, batch in enumerate(dataloader):
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 630, in next
data = self._next_data()
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 673, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 55, in fetch
return self.collate_fn(data)
File "/home/zsy/MKGformer/MKG/data/data_module.py", line 103, in call
label = [feature.pop("label") for feature in features]
File "/home/zsy/MKGformer/MKG/data/data_module.py", line 103, in
label = [feature.pop("label") for feature in features]
KeyError: 'label'
Exception ignored in: <function tqdm.del at 0x73a1b43b2430>
Traceback (most recent call last):
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/tqdm/std.py", line 1090, in del
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/tqdm/std.py", line 1303, in close
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/tqdm/std.py", line 1481, in display
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/tqdm/std.py", line 1093, in repr
File "/opt/conda/envs/MKGformer/lib/python3.8/site-packages/tqdm/std.py", line 1443, in format_dict
TypeError: cannot unpack non-iterable NoneType object

@njcx-ai
Copy link
Collaborator

njcx-ai commented Jan 16, 2025

您好,建议您检测下看看下载后的数据集读取后是否包含“label”字段呢

@ZuoMM-f
Copy link
Author

ZuoMM-f commented Jan 16, 2025

{'input_ids': [101, 1996, 6412, 1997, 103, 2003, 2008, 1037, 2223, 1997, 2037, 2219, 2003, 1037, 2826, 2137, 4038, 1011, 3689, 2143, 2008, 4136, 1037, 7214, 3550, 4070, 1997, 1996, 2613, 1011, 2166, 2035, 1011, 2137, 3057, 2658, 3598, 2223, 1012, 2856, 2011, 10647, 5832, 1010, 1996, 2143, 3340, 3419, 9180, 2015, 1010, 20277, 2532, 4482, 1010, 15820, 1051, 1005, 18016, 1010, 1998, 11284, 1012, 102], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'label': 9929, 'entity': '/m/02ndy4'}
Epoch 0: 80%|███████████████████████████████████████████████████████████████████████████████████▏ | 935/1169 [47:44<11:56, 3.06s/it, loss=11.2, v_num=10, hits10=0.000, hits1=0.000]
{'input_ids': [101, 1996, 6412, 1997, 103, 2003, 2008, 21173, 1011, 18864, 2003, 1996, 22037, 1997, 1996, 7032, 2163, 1997, 2762, 1010, 9605, 2087, 1997, 1996, 3439, 11068, 1997, 18864, 1998, 1996, 2670, 2112, 1997, 1996, 2280, 11068, 1997, 21173, 1012, 2049, 3007, 2103, 2003, 20963, 1025, 2060, 3862, 3655, 2024, 11320, 12750, 1010, 13109, 28812, 1998, 11265, 2819, 4609, 6238, 1012, 1996, 2280, 2394, 102], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
没有找到 'label' 键 {'input_ids': [101, 1996, 6412, 1997, 103, 2003, 2008, 21173, 1011, 18864, 2003, 1996, 22037, 1997, 1996, 7032, 2163, 1997, 2762, 1010, 9605, 2087, 1997, 1996, 3439, 11068, 1997, 181998, 1996, 2670, 2112, 1997, 1996, 2280, 11068, 1997, 21173, 1012, 2049, 3007, 2103, 2003, 20963, 1025, 2060, 3862, 3655, 2024, 11320, 12750, 1010, 13109, 28812, 1998, 11265, 2819, 4609, 6238, 1012, 1996, 2280, 2394, 102], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}

label值貌似是生成的一个数,不是所有的entity都没有label值,打印出来之后发现大部分有生成的label值,后面的没有,但是没有label的好像也没有entity,不知道这段代码是否有问题

@ZuoMM-f
Copy link
Author

ZuoMM-f commented Jan 18, 2025

Image
有没有可能是data_module文件中,关于label列表没有对缺少“label”key的处理导致的问题,"labels",“entity”都有处理。

或者需要对缺少图片实体添加文件夹这样的处理吗?恳请作者回答我的问题,非常感谢

@njcx-ai
Copy link
Collaborator

njcx-ai commented Jan 20, 2025

您好,我记得应该是有需要对缺少图片实体添加文件夹这样的处理的,data_module中之前我们关于“label”key也都是能跑通的呀。

@zxlzr
Copy link
Contributor

zxlzr commented Jan 26, 2025

请问您的问题解决了吗

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

3 participants