;
one_hot(label, depth = 10)方法将 0~9 的数字编码标签转换为 one-hot 编码的标签。...比如将数字编码 5 转换为 one-hot 编码为 [0,0,0,0,1,0,0,0,0,0](由于此时假设为十个类别,因此 one-hot 编码后的向量维度为 10 维)。...label转换为one-hot编码y
'''
y = torch.zeros(label.size(0), depth)
idx = torch.LongTensor(label...基于 PyTorch 有很多工具集,比如:处理自然语言的 torchtext,处理音频的 torchaudio 和 处理图像视频的 torchvision,这些工具集可以独立于 PyTorch 的使用。...中的一些参数:
'mnist_data':MNIST 数据集所在的文件夹,我直接设置在当前路径。