
pytorch
学习和环境配置
xzw96
写的都是自己碰到的问题。
展开
-
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same原因Input type and weight type not be samefixeddevice = torch.device("cpu")model = MyModel()model.to(device)input.to(device)model(input)# cpu o原创 2021-08-17 17:56:49 · 193 阅读 · 0 评论 -
Pytorch实现卷积运算(互相关)
Pytorch实现卷积运算(互相关)1. 实现过程在二维互相关运算中,卷积窗口从输入数组的最左上方开始,按从左往右、从上往下的顺序,依次在输入数组上滑动。当卷积窗口滑动到某一位置时,窗口中的输入子数组与核数组按元素相乘并求和,得到输出数组中相应位置的元素。图中的输出数组高和宽分别为2,其中的4个元素由二维互相关运算得出:0×0+1×1+3×2+4×3=19,1×0+2×1+4×2+5×3=25,3×0+4×1+6×2+7×3=37,4×0+5×1+7×2+8×3=43.0\times0+1\tim原创 2021-08-14 09:37:32 · 1586 阅读 · 0 评论 -
Torch搭建网络层的三种方式
Torch搭建网络层的三种方式import torchimport torch.nn as nn from collections import OrderedDictclass LinearNet(nn.Module): def __init__(self, n_feature): super(LinearNet, self).__init__() self.linear = nn.Linear(n_feature, 1) def for原创 2021-08-11 22:05:10 · 902 阅读 · 0 评论 -
ModuleNotFoundError: No module named ‘torchtext‘
1. 报错:ModuleNotFoundError: No module named ‘torchtext’\Desktop\Python\Dive-into-DL-PyTorch-master\code\d2lzh_pytorch\utils.py in <module> 19 import torchvision 20 import torchvision.transforms as transforms---> 21 import torchtext原创 2021-08-10 23:25:21 · 5402 阅读 · 2 评论 -
Tensor 和 NumPy 相互转换
Tensor和NumPy相互转换我们很容易用numpy()和from_numpy()将Tensor和NumPy中的数组相互转换。但是需要注意的一点是: 这两个函数所产生的Tensor和NumPy中的数组共享相同的内存(所以他们之间的转换很快),改变其中一个时另一个也会改变!1. Tensor转NumPya = torch.ones(6)b = a.numpy()print(a, b)a += 1print(a, b)b += 1print(a, b)tensor([1., 1.转载 2021-08-10 17:34:44 · 54015 阅读 · 0 评论 -
PyTorch入门 DeepLearning入门
PyTorch入门 DeepLearning入门PyTorch中文文档深度学习入门吴恩达深度学习deeplearning.ai-哔哩哔哩Dive-into-DL-PyTorch《动手学深度学习》(PyTorch版)-哔哩哔哩PyTorch深度学习入门教程-哔哩哔哩PyTorch实战教程相关pdfPyTorch中文文档: 基本的torch语法深度学习入门:深度学习基本知识Dive-into-DL-PyTorch: 结合深度学习PyTorch实战教程: 小项目实战PyTo原创 2021-08-09 11:53:33 · 419 阅读 · 0 评论 -
Pytorch搭建LeNet5
Pytorch搭建LeNet51. LeNet神经网络介绍LeNet神经网络由深度学习三巨头之一的Yan LeCun提出,他同时也是卷积神经网络 (CNN,Convolutional Neural Networks)之父。LeNet主要用来进行手写字符的识别与分类,并在美国的银行中投入了使用。LeNet的实现确立了CNN的结构,现在神经网络中的许多内容在LeNet的网络结构中都能看到,例如卷积层,Pooling层,ReLU层。虽然LeNet早在20世纪90年代就已经提出了,但由于当时缺乏大规模的训练数原创 2021-08-06 14:58:12 · 1340 阅读 · 0 评论 -
PyTorch官方教程中文版
PyTorch官方教程中文版https://pytorch123.com/原创 2021-07-22 02:15:24 · 865 阅读 · 0 评论 -
RuntimeError: NCCL error in: /pytorch/torch/lib/c10d/ProcessGroupNCCL.cpp:784 torch
-- Process 6 terminated with the following error:Traceback (most recent call last): File "/media/home/intern/anaconda3/envs/torch17/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 19, in _wrap fn(i, *args) File "/media/home/inter原创 2021-07-20 19:48:58 · 7957 阅读 · 2 评论 -
Torch 、torchvision 、Python 版本对应关系以及安装 GPU 或 CPU 版本的 pytorch
torch- torchvision- python版本对应关系原创 2021-06-30 11:07:15 · 132136 阅读 · 3 评论