Tencent / NeuralNLP-NeuralClassifier

An Open-source Neural Hierarchical Multi-label Text Classification Toolkit
Other
1.85k stars 406 forks source link

HMCN RuntimeError: The size of tensor a (13) must match the size of tensor b (10) at non-singleton dimension 1 #104

Closed Tesla-jiang closed 2 years ago

Tesla-jiang commented 2 years ago

很感谢你们的开源,我在使用HMCN适配我的数据集的时候遇到了如下问题,貌似是global_layer_output 和 local_layer_output 输出维度的问题,需要调整模型内部结构么?或者有其他修改建议? Epoch 1 is training... 0%| | 0/1726 [00:04<?, ?it/s] Traceback (most recent call last): File "D:/2021/Code/NeuralNLP-NeuralClassifier/train.py", line 250, in train(config) File "D:/2021/Code/NeuralNLP-NeuralClassifier/train.py", line 218, in train trainer.train(train_data_loader, model, optimizer, "Train", epoch) File "D:/2021/Code/NeuralNLP-NeuralClassifier/train.py", line 99, in train return self.run(data_loader, model, optimizer, stage, epoch, ModeType.TRAIN) File "D:/2021/Code/NeuralNLP-NeuralClassifier/train.py", line 130, in run (global_logits, local_logits, logits) = model(batch) File "D:\Miniconda3\envs\Torch1.0\lib\site-packages\torch\nn\modules\module.py", line 489, in call result = self.forward(*input, *kwargs) File "D:\2021\Code\NeuralNLP-NeuralClassifier\model\classification\hmcn.py", line 113, in forward return global_layer_output, local_layer_output, 0.5 global_layer_output + 0.5 * local_layer_output
RuntimeError: The size of tensor a (13) must match the size of tensor b (10) at non-singleton dimension 1

另外,eval.py和predict.py貌似并没有适配 HMCN模型

yszc-wy commented 2 years ago

同样遇到这个问题

coderbyr commented 2 years ago

global_layer_output的dim应该等于每个local_layer的dim之和,比如每一个local输出维度分为为 l1, l2, l3, 那么global的最终输出应该等于l1+l2+l3, 请检查下配置是否正确