Notes on Section 3.7

bobown_yao

这一节主要是简要的实现softmax

库初始化

Image: image_001

神经网络层初始化和权重初始化(注意到只有该层是线性层Linear时我们才应用权重的正态分布初始化)

Image: image_002这里一共有两层,一层是用来解包展平数据的也就是flatten层

Image: image_003

这些名称是指明的,需要准确使用

我们注意到softmax函数使用了指数来规范化,但这个可能导致数据溢出的问题,所以我们可以做如下优化

Softmax

Image: image_004

Loss(因为需要取对数)

Image: image_005

合并了softmax函数和loss函数的计算,达到了优化的效果

完整训练代码如下

Image: image_006

  • Title: Notes on Section 3.7
  • Author: bobown_yao
  • Created at : 2025-12-09 00:00:00
  • Updated at : 2026-01-17 16:18:07
  • Link: https://bobownyao.github.io/2025/12/09/Notes-on-Section-3-7/
  • License: All Rights Reserved © bobown_yao
On this page
Notes on Section 3.7