一、模型选择
1 激活函数
1.1 sigmoid 函数
用途:二分类任务

1 | import torch |
1.2 sign 阶跃函数

1 | import torch |
1.3 整流线性单元函数ReLU

1 | import torch |
1.4 tanh 双曲正切函数

1.5 softmax 函数
用途:多分类任务

1 | import torch |
2 实现正向传播
2.1 任务

2.2 代码
1 | import torch |
2.3 结果

二、损失函数
| 问题分类 | 使用的损失函数 | 调用的方法 |
|---|---|---|
| 回归问题 | 误差平方和SSE | criterion = MSELoss(reduction = "sum") |
| 二分类 | 二分类交叉熵损失 | ① criterion = nn.BCELoss ② criterion = nn.BCEWithLogitsLoss() |
| 多分类 | 交叉熵损失函数 | ① nn.LogSoftmax(dim = 1) 加上nn.NLLLoss()② criterion = nn.CrossEntropyLoss() |
1 交叉熵损失函数

1.1 二分类交叉熵损失函数

1.2 多分类交叉熵损失函数

三、优化算法
1 最小二乘法
1.1 数学推导

1.2 几何意义

1.3概率视角

2 高斯分布
