Processing math: 100%

随笔分类 -  Pytorch

摘要:首先不妨假设最简单的一种情况: 假设GD的损失函数: 那么计算梯度有: 第一种正确的方式: import torch from torch import nn def set_requires_grad(net: nn.Module, mode=True): for p in net.pa 阅读全文
posted @ 2021-08-09 03:17 Dilthey 阅读(1653) 评论(0) 推荐(0) 编辑
摘要:VGG 主要有两种结构,分别是 VGG16 和 VGG19,两者并没有本质上的区别,只是网络深度不一样。 对于给定的感受野,采用堆积的小卷积核是优于采用大的卷积核的,因为多层非线性层可以增加网络深度来保证学习更复杂的模式,而且代价还比较小(参数更少)。 比如,三个步长为 1 的 $3 \time 阅读全文
posted @ 2020-02-28 13:31 Dilthey 阅读(5003) 评论(0) 推荐(0) 编辑
摘要:关于该类: torch.nn.Linear(in_features, out_features, bias=True) 可以对输入数据进行线性变换: y=xAT+b in_features: 输入数据的大小。 out_features: 输出数据的大小。 bias: 是否添加一个可学 阅读全文
posted @ 2020-02-28 11:40 Dilthey 阅读(4808) 评论(0) 推荐(0) 编辑
摘要:先看函数参数: torch.flatten(input, start_dim=0, end_dim=-1) input: 一个 tensor,即要被“推平”的 tensor。 start_dim: “推平”的起始维度。 end_dim: “推平”的结束维度。 首先如果按照 start_dim 和 e 阅读全文
posted @ 2020-02-28 11:01 Dilthey 阅读(28819) 评论(0) 推荐(9) 编辑
摘要:先看一下CLASS有哪些参数: torch.nn.Conv2d( in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros' ) 阅读全文
posted @ 2020-02-24 21:51 Dilthey 阅读(2232) 评论(0) 推荐(2) 编辑
摘要:参考自《Pytorch autograd,backward详解》: 1 Tensor Pytorch中所有的计算其实都可以回归到Tensor上,所以有必要重新认识一下Tensor。 如果我们需要计算某个Tensor的导数,那么我们需要设置其.requires_grad属性为True。为方便说明,在本 阅读全文
posted @ 2020-02-24 20:29 Dilthey 阅读(1850) 评论(0) 推荐(0) 编辑
摘要:先看一下它的参数: norm(p='fro', dim=None, keepdim=False, dtype=None) p: the order of norm. 一般来说指定 p=1,2 等值表示 $(\sum_{i} \left | x_i \right |^{p})^{(1/p)} 阅读全文
posted @ 2020-02-24 20:28 Dilthey 阅读(2539) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示