pytorch 实现L2和L1正则化regularization的操作

qqarmor37980 20 0 pdf 2021-07-03 09:07:21

很多时候如果对b 进行L2正则化将会导致严重的欠拟合,因此这个时候一般只需要对权值w进行正则即可。这是因为你的loss_fun损失函数没有把权重W的损失加上。采用torch.optim的优化器实现正则化的方法,是没问题的!Github项目源码:为了,解决这些问题,我特定自定义正则化的方法,类似于TensorFlow正则化实现方法。并且随着正则化的权重lambda越大,表现的更加平滑。此外更改参数p,如当p=0表示L2正则化,p=1表示L1正则化。

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

pytorch 实现L2和L1正则化regularization的操作

用户评论
请输入评论内容
评分:
暂无评论