![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
关于Pytorch的那些事儿
凤舞九天cw
计算机科学与技术专业,主要研究方向为图像处理与计算机视觉
展开
-
RuntimeError: cuda runtime error (46) : all CUDA-capable devices are busy or unavailable at /pytorch
最近在训练YOLOV5时,发现以下问题:Traceback (most recent call last): File "train.py", line 399, in <module> train(hyp) File "train.py", line 228, in train for i, (imgs, targets, paths, _) in pbar: # batch -------------------------------------------原创 2020-11-26 10:06:38 · 3940 阅读 · 0 评论 -
Pytorch中.data与.detach()的区别和作用
在Pytorch中,创建模型和数据运算传递时,经常会使用到tensor.data和tensor.detach(),对于这两种使用方式,都是对Variable中的tensor进行处理,但是都不进行梯度计算和被进行梯度跟踪,即requires_grad=False,简单来说,他们的区别如下:相同点两者都和原数据共享同一块数据;都和原来数据的计算历史无关;requires_grad = Fa...原创 2020-01-01 11:54:58 · 3568 阅读 · 0 评论 -
Pytorch中的哈达玛积(Hadamard product)与矩阵乘积(Matrix product)的区别
在Pytorch中tensor处理时我们经常会遇到矩阵之间的乘法运算,而对于不同的要求会有不同的计算方式,特别是Hadamard积与矩阵乘积之间的差别。哈达玛积:对于两个举证或者数组A和B,A和B的维度至少是2,如果是二位数组,则AB两个数组相对应的维度的值必须相等,例如A为m*n的数组,仅当数组B满足维度为m*n时,A与B才能进行哈达玛积运算,具体计算方式如下:代码示例:a =...原创 2019-12-18 21:05:12 · 12316 阅读 · 3 评论 -
CUDA错误:cuDNN error: CUDNN_STATUS_NOT_INITIALIZED与CUDA error: device-side assert triggered
在运行pytorch模型进行训练时,CUDA报错:"/pytorch/aten/src/THC/THCTensorScatterGather.cu:188: void THCudaTensor_scatterFillKernel(TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, Real, int, I...原创 2019-11-25 16:01:18 · 7220 阅读 · 2 评论 -
Pytorch中针对不同层的weight和bias设置不同的学习率
在训练模型时,有时候依据需求需要对模型的不同层(比如convolutional layer, linear layer等)或者不同层的weght和bias设置不同的学习率,针对这个问题,我们有以下几种方式解决:以5层卷积的模型为例:class Net5(nn.Module): def __init__(self): super(Net5, self).__init...原创 2019-10-01 18:27:49 · 4078 阅读 · 0 评论 -
Pytorch框架读取数据,训练模型,测试模型的基本流程
Part one:读取数据以图像压缩模型为例,输入数据为图像数据,假设图像数据集是PNG格式的图片。image_extentions = ['.png', '.PNG', '.jpg', '.JPG']class My_Dataset(Dataset): def __init__(self, image_root, transform=None): supe...原创 2019-11-12 20:02:24 · 1215 阅读 · 1 评论