pytorch_ssim.ssim()TypeError:conv2d()receivedaninvalidcombinationofarguments-got(Tensor,
原创目录
情况
batch_ssim = pytorch_ssim.ssim(img1, img2).item()
TypeError: conv2d() received an invalid combination of arguments - got (Tensor, Tensor, padding=float, groups=int), but expected one of:
- (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, tuple of ints padding, tuple of ints dilation, int groups)
- (Tensor input, Tensor weight, Tensor bias, tuple of ints stride, str padding, tuple of ints dilation, int groups)
原因A:批输入图片
该函数目前只接受一对图片作为输入,而不是整个epoch,因此在验证集批处理大小> 1 的情况下不可用。
The format of the input data is as follows:
torch.Size([4, 3, 256, 256])
torch.float32
torch.Size([4, 3, 256, 256])
torch.float32
解决:
循环每个图像以获取 SSIM 值
原因B:图像尺寸不一致
解决:resize
SSIM简介
结构相似性指数(SSIM)度量从一幅图像中提取3个关键特征:
-
亮度
-
对比度
-
结构
-
与其在全局范围内应用上述度量值(即一次在图像上的所有区域),不如在局部范围内应用这些度量值(即在图像的小部分中,然后取整体的平均值)。
这种方法通常被称为平均结构相似度指数。
-
使用一个11x11圆对称高斯加权函数(基本上就是一个11x11矩阵,其值来自高斯分布)在整个图像上逐像素移动。在每一步中,在局部窗口内计算局部统计信息和SSIM索引。
-
只需取所有局部SSIM值的平均值,就得到了 全局的 SSIM值。
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除