![](https://img-blog.csdnimg.cn/20200329215702433.jpeg?x-oss-process=image/resize,m_fixed,h_224,w_224)
Pytorch
pytorch学习
v-space
语音识别、声纹识别、语音唤醒
展开
-
pytorch 计算模型参数量
sum(torch.numel(parameter) for parameter in model.parameters())原创 2021-05-13 19:56:09 · 681 阅读 · 0 评论 -
解决:_pickle.UnpicklingError: A load persistent id instruction was encountered,
描述在使用pytorch合并模型时出错原因保存模型和合并模型时pytorch版本不一致。合并模型时切换为保存模型的pytorch版本即可。原创 2021-01-12 10:18:13 · 6002 阅读 · 10 评论 -
解决RuntimeError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
问题描述:x = [[0.1,0.2,0.1], [0.4,0.1,0.3]]y = [1, 0]loss_fn = nn.CrossEntropyLoss()loss = loss_fn(x, y)x为特征矩阵,y为标签。x对应维度应为batch_size x dim。y对应维度应为batch_size。当使用交叉熵时,当最后一个batch_size为1时。造成x维度变成1,y也为1。此时nn.CrossEntropyLoss()误将x识别成y产生如下报错。RuntimeErr.原创 2020-09-17 19:09:00 · 4238 阅读 · 0 评论 -
为什么要使用contiguous()
有一些对Tensor的操作不会真正改变Tensor的内容(真实维度),不会开辟新内存空间来存放处理之后的数据,新数据与原始数据共享同一块内存,改变的仅仅是Tensor中字节位置的索引。这些操作如下:narrow(), view(), expand(), transpose()因此在进行这些操作之前,需要使用contiguous()确保将数据划分到整块内存。参考资料[2]说明很详细,非常推荐看一下。参考:[1] 理解PyTorch的contiguous() [CSDN][2] pytorch中原创 2020-05-20 11:55:12 · 1100 阅读 · 0 评论 -
Linux下PyTorch、CUDA Toolkit 及显卡驱动版本对应关系(附详细安装步骤)
Linux下PyTorch、CUDA Toolkit 及显卡驱动版本对应关系(附详细安装步骤)原创 2020-03-30 15:20:13 · 64384 阅读 · 56 评论 -
Linux下conda使用清华镜像源快速安装PyTorch
Pytorch官网官网下载比较慢采用清华镜像conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/c...原创 2020-03-29 15:49:11 · 14560 阅读 · 8 评论 -
解决Error(s) in loading state_dict for *** :Missing key(s) in state_dict:Unexpected key(s) in state_di
实验环境:Linuxpython3.7pytorch1.1.0问题:RuntimeError: Error(s) in loading state_dict for Transformer: Missing key(s) in state_dict: "encoder.embed.conv.0.weight","...". Unexpected k...原创 2020-03-28 09:34:06 · 6040 阅读 · 0 评论 -
BUG待解决
1.安装apex后,运行程序报错 Original ImportError was: ModuleNotFoundError("No module named 'amp_C'")原创 2020-03-26 19:52:40 · 217 阅读 · 0 评论 -
pytorch使用Apex混合精度加速训练
Apex官网:https://nvidia.github.io/apex/amp.html#使用原因:这篇博客讲的非常好PyTorch必备神器 | 唯快不破:基于Apex的混合精度加速1.安装使用pip安装后会出错TypeError: Class advice impossible in Python3. Use the @Implementer class decorat...原创 2020-03-26 15:20:57 · 2652 阅读 · 0 评论