zjunlp / DeepKE

[EMNLP 2022] An Open Toolkit for Knowledge Graph Extraction and Construction
http://deepke.zjukg.cn/
MIT License
3.38k stars 673 forks source link

问题请求解答,RE使用GCN模型预测时出错 #232

Closed NEUtangyu closed 1 year ago

NEUtangyu commented 1 year ago

Describe the question

A clear and concise description of what the question is. RE模型使用GCN,训练时没有什么问题,在预测时,报了这个错误:(使用的是python3.8,torch1.10) Traceback (most recent call last): File "D:\pycharmprojects\deepke\deepke-main\example\re\standard\predict.py", line 141, in main y_pred = model(x) File "D:\Anaconda\envs\deepke\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "D:\pycharmprojects\deepke\deepke-main\src\deepke\relation_extraction\standard\models\GCN.py", line 30, in forward output = self.gcn(inputs, adj) File "D:\Anaconda\envs\deepke\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(input, **kwargs) File "D:\pycharmprojects\deepke\deepke-main\src\deepke\attribution_extraction\standard\module\GCN.py", line 33, in forward Ax = adj.bmm(outputs) RuntimeError: Expected batch2_sizes[0] == bs && batch2_sizes[1] == contraction_size to be true, but got false. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

Environment (please complete the following information):

Screenshots

If applicable, add screenshots to help explain your problem. image

Additional context

Add any other context about the problem here.

tlk1997 commented 1 year ago

你好,问题已修复,修改第133行为 =》 adj = torch.empty(1,512,512).random_(2),或者拉取最新代码

NEUtangyu commented 1 year ago

谢谢,已经解决啦