D:\Anaconda\python.exe D:\py\text2.py (56, 29) D:\Anaconda\lib\site-packages\xarray\core\nanops.py:142: RuntimeWarning: Mean of empty slice return np.nanmean(a, axis=axis, dtype=dtype) D:\Anaconda\lib\site-packages\numpy\lib\function_base.py:2691: RuntimeWarning: invalid value encountered in true_divide c /= stddev[:, None] D:\Anaconda\lib\site-packages\numpy\lib\function_base.py:2692: RuntimeWarning: invalid value encountered in true_divide c /= stddev[None, :] D:\Anaconda\lib\site-packages\torch\nn\modules\loss.py:536: UserWarning: Using a target size (torch.Size([40])) that is different to the input size (torch.Size([40, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.mse_loss(input, target, reduction=self.reduction) Traceback (most recent call last): File "D:\py\text2.py", line 154, in <module> loss.backward()#误差反向传播,计算新的更新参数值 File "D:\Anaconda\lib\site-packages\torch\_tensor.py", line 489, in backward self, gradient, retain_graph, create_graph, inputs=inputs File "D:\Anaconda\lib\site-packages\torch\autograd\__init__.py", line 199, in backward allow_unreachable=True, accumulate_grad=True) # Calls into the C++ engine to run the backward pass RuntimeError: Found dtype Double but expected Float
时间: 2023-07-21 07:18:50 浏览: 377
已有Python安装Anaconda,出现warning、报错及解决办法
根据你提供的信息,看起来是在运行一个 Python 脚本出现了一些错误。具体来说,有一个运行时警告和一个运行时错误。警告是在计算均值时出现了一个空切片,而错误是在使用 PyTorch 进行误差反向传播时发生的。根据错误消息,你的代码似乎期望一个 Float 类型的张量,但实际上得到了一个 Double 类型的张量。你可以检查代码中的张量类型,并确保它们与你期望的类型一致。另外,你也可以检查输入和目标张量的大小,确保它们具有相同的大小。
阅读全文