From 3239fd991f0c104cb729537da8f1989415f63a5b Mon Sep 17 00:00:00 2001 From: QCQCQC <1220204124@zust.edu.cn> Date: Fri, 25 Apr 2025 18:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vector_tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vector_tests.py b/vector_tests.py index 7e1ac0e..c0ef36f 100644 --- a/vector_tests.py +++ b/vector_tests.py @@ -14,27 +14,27 @@ model = SentenceTransformer('all-MiniLM-L6-v2') # 模拟错误数据库 error_db = [ { - "error": """Traceback (most recent call last):\n File \"image_error.py\", line 55, in \n loss = criterion(outputs, labels)\n File \"module.py\", line 1553, in _wrapped_call_impl\n return self._call_impl(*args, **kwargs)\n File \"module.py\", line 1562, in _call_impl\n return forward_call(*args, **kwargs)\n File \"loss.py\", line 1188, in forward\n return F.cross_entropy(input, target, weight=self.weight,\n File \"functional.py\", line 3104, in cross_entropy\n return cross_entropy_loss(input, target, ...)\nIndexError: Target 15 is out of bounds.\n""", + "error": "Traceback (most recent call last):\n File \"image_error.py\", line 55, in \n loss = criterion(outputs, labels)\n File \"module.py\", line 1553, in _wrapped_call_impl\n return self._call_impl(*args, **kwargs)\n File \"module.py\", line 1562, in _call_impl\n return forward_call(*args, **kwargs)\n File \"loss.py\", line 1188, in forward\n return F.cross_entropy(input, target, weight=self.weight,\n File \"functional.py\", line 3104, in cross_entropy\n return cross_entropy_loss(input, target, ...)\nIndexError: Target 15 is out of bounds.\n", "solution": "可能是 labels 中的值超出了分类数量的范围。检查模型最后一层的输出维度是否正确。" }, { - "error": """Traceback (most recent call last):\n File \"rnn_error.py\", line 1, in \n import torch\nModuleNotFoundError: No module named 'torch'\n""", + "error": "Traceback (most recent call last):\n File \"rnn_error.py\", line 1, in \n import torch\nModuleNotFoundError: No module named 'torch'\n", "solution": "检查路径是否存在,或模型文件是否已正确保存。" }, { - "error": """Traceback (most recent call last):\n File \"cnn_success.py\", line 51, in \n loss.backward()\n File \"_tensor.py\", line 521, in backward\n torch.autograd.backward(...)\n File \"__init__.py\", line 289, in backward\n _engine_run_backward(...)\n File \"graph.py\", line 768, in _engine_run_backward\n return run_backward(...)\nKeyboardInterrupt\n""", + "error": "Traceback (most recent call last):\n File \"cnn_success.py\", line 51, in \n loss.backward()\n File \"_tensor.py\", line 521, in backward\n torch.autograd.backward(...)\n File \"__init__.py\", line 289, in backward\n _engine_run_backward(...)\n File \"graph.py\", line 768, in _engine_run_backward\n return run_backward(...)\nKeyboardInterrupt\n", "solution": "程序被用户中断 (KeyboardInterrupt)。这不是一个典型的代码错误,可能是手动停止了程序。" }, { - "error": """Traceback (most recent call last):\n File \"cnn_success.py\", line 1, in \n import torch\nModuleNotFoundError: No module named 'torch'\n""", + "error": "Traceback (most recent call last):\n File \"cnn_success.py\", line 1, in \n import torch\nModuleNotFoundError: No module named 'torch'\n", "solution": "找不到模块torch, 请检查是否已安装 PyTorch。" }, { - "error": """Traceback (most recent call last):\n File \"rnn_error.py\", line 40, in \n loss = criterion(output, label.unsqueeze(0))\n File \"module.py\", line 1553, in _wrapped_call_impl\n return self._call_impl(*args, **kwargs)\n File \"module.py\", line 1562, in _call_impl\n return forward_call(*args, **kwargs)\n File \"loss.py\", line 1188, in forward\n return F.cross_entropy(input, target, weight=self.weight,\n File \"functional.py\", line 3104, in cross_entropy\n return cross_entropy_loss(input, target, ...)\nValueError: Expected input batch_size (2) to match target batch_size (1).\n""", + "error": "Traceback (most recent call last):\n File \"rnn_error.py\", line 40, in \n loss = criterion(output, label.unsqueeze(0))\n File \"module.py\", line 1553, in _wrapped_call_impl\n return self._call_impl(*args, **kwargs)\n File \"module.py\", line 1562, in _call_impl\n return forward_call(*args, **kwargs)\n File \"loss.py\", line 1188, in forward\n return F.cross_entropy(input, target, weight=self.weight,\n File \"functional.py\", line 3104, in cross_entropy\n return cross_entropy_loss(input, target, ...)\nValueError: Expected input batch_size (2) to match target batch_size (1).\n", "solution": "检查模型输出和标签的形状是否匹配。确保它们在 batch_size 维度上是一致的。" }, { - "error": """Syntax error in command""", + "error": "Syntax error in command", "solution": "检查代码中的语法错误。可能是缺少括号、引号或其他语法问题。" } ]