Tencent / NeuralNLP-NeuralClassifier

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

RuntimeError: mat1 and mat2 shapes cannot be multiplied (128x256 and 1x256) on TextCNN #81

Closed SeekPoint closed 3 years ago

SeekPoint commented 3 years ago

(.venv) C:\ghprj\NeuralNLP-NeuralClassifier>python train.py conf/train.json

Size of doc_topic dict is 0 Traceback (most recent call last): File "train.py", line 258, in train(config) File "train.py", line 224, in train trainer.train(train_data_loader, model, optimizer, "Train", epoch) File "train.py", line 102, in train ModeType.TRAIN) File "train.py", line 121, in run logits = model(batch) File "C:\ghprj\NeuralNLP-NeuralClassifier.venv\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, *kwargs) File "C:\ghprj\NeuralNLP-NeuralClassifier\model\classification\textrnn.py", line 92, in forward doc_embedding = self.sum_attention(output) File "C:\ghprj\NeuralNLP-NeuralClassifier.venv\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(input, **kwargs) File "C:\ghprj\NeuralNLP-NeuralClassifier\model\layers.py", line 42, in forward return self.dropout(torch.matmul(alpha, inputs).squeeze()) RuntimeError: mat1 and mat2 shapes cannot be multiplied (128x256 and 1x256)

(.venv) C:\ghprj\NeuralNLP-NeuralClassifier>git diff diff --git a/conf/train.json b/conf/train.json index 0af9c91..82d5b2f 100644 --- a/conf/train.json +++ b/conf/train.json @@ -6,8 +6,8 @@ "hierar_taxonomy": "data/rcv1.taxonomy", "hierar_penalty": 0.000001 },

coderbyr commented 3 years ago

update notes about how to train a classifier, please refer README(https://github.com/Tencent/NeuralNLP-NeuralClassifier#how-to-train-a-non-hierarchical-classifier)