pytorch13->loss损失函数的简单应用
import torch
from torch.nn import L1Loss, MSELoss
from torch import nn# 1. 定义输入和目标(注意:需要 float32 类型)
inputs torch.tensor([1, 2, 3], dtypetorch.float32)
targets torch.tensor([1, 2, 5], dtypetorch.float32)# 2. …
2026/6/25 16:38:09