
pytorch
文章平均质量分 58
沙小菜
菜鸟要飞
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
l1、l2正则化在pytorch框架下的实现方式
转载PyTorch训练模型添加L1/L2正则化的两种实现方式_hlld__的博客-优快云博客_pytorch添加正则化 在使用PyTorch训练模型时,可使用三种方式添加L1/L2正则化:一种是添加正则化项到损失函数中,另一种是在backward()之后,添加正则化项到参数变量的梯度中,然后再进行step(),一种是torch.optim优化器实现L2正则化 方式一:添加到损失函数 def l1_regularization(model, l1_alpha): l1_loss = []..原创 2022-01-13 17:09:54 · 5482 阅读 · 3 评论 -
pytorch提取某一层的特征图
直接在forward函数里,return output_con2.data 如: def forward(): ... base_out = self.base_model(input_var) output = self.new_fc(base_out) return output 想要输出base_out 只需要加入 out_...原创 2019-08-03 21:28:19 · 7260 阅读 · 0 评论