import torch # 假设输出和目标 target = torch.tensor([2, 1, 0]) # 真实的标签 print(target.size(0)) target.size(0) 被用来获取批次中样本的数量