独热编码
独热编码(one-hot vector),一个向量,除了有一位是 \(1\) 外,其余维度均为 \(0\)。
Softmax 函数
多分类问题中,网络输出层的激活函数,对输出值进行归一化操作,将其全部转化为概率(和为1)。
\[softmax\left ( x \right )_i =\frac{exp\left ( x_i \right ) }{ {\textstyle \sum_{j}^{}exp\left ( x_j \right ) } }
\]
MSEloss
计算均方误差的损失函数。
\[mse = \frac{1}{n} \sum \left ( y_{pred} -y_{true}\right ) ^2
\]
import torch
import torch.nn as nn
loss = nn.MSELoss(outputs, targets)