欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 维修 > 【Python/Pytorch - 网络模型】-- 手把手搭建3D VGG感知损失模型

【Python/Pytorch - 网络模型】-- 手把手搭建3D VGG感知损失模型

2024/10/24 10:17:37 来源:https://blog.csdn.net/wangshuqian1314/article/details/139662076  浏览:    关键词:【Python/Pytorch - 网络模型】-- 手把手搭建3D VGG感知损失模型

在这里插入图片描述
文章目录

文章目录

  • 00 写在前面
  • 01 基于Pytorch版本的3D VGG代码
  • 02 论文下载

00 写在前面

感知损失:对于提升图片的肉眼可见细节,效果十分明显;对于一些指标如(SSIM、PSNR)这些,效果不明显。

在01中,可以根据3D VGG的网络结构,进行模块化编程,主要包括VGG3D模块。

在模型调试过程中,可以先通过简单测试代码,进行代码调试。

01 基于Pytorch版本的3D VGG代码

# 库函数调用
import torch
import torch.nn as nn# VGG3D模块
class CustomVGG3D(nn.Module):def __init__(self, in_channels=3, out_channels=2):super(CustomVGG3D, self).__init__()self.features = nn.Sequential(nn.Conv3d(in_channels, 64, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.Conv3d(64, 64, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.MaxPool3d(kernel_size=(2, 2, 2), stride=(2, 2, 2)),nn.Conv3d(64, 128, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.Conv3d(128, 128, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.MaxPool3d(kernel_size=(2, 2, 2), stride=(2, 2, 2)),nn.Conv3d(128, 256, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.Conv3d(256, 256, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.Conv3d(256, 256, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),nn.Conv3d(256, 256, kernel_size=(3, 3, 3), padding=(1, 1, 1)),nn.ReLU(inplace=True),# nn.MaxPool3d(kernel_size=(2, 2, 2), stride=(2, 2, 2)),# nn.Conv3d(256, 512, kernel_size=(3, 3, 3), padding=(1, 1, 1)),# nn.ReLU(inplace=True),# nn.Conv3d(512, 512, kernel_size=(3, 3, 3), padding=(1, 1, 1)),# nn.ReLU(inplace=True),# nn.Conv3d(512, 512, kernel_size=(3, 3, 3), padding=(1, 1, 1)),# nn.ReLU(inplace=True),# nn.MaxPool3d(kernel_size=(2, 2, 2), stride=(2, 2, 2)),# nn.Conv3d(512, 512, kernel_size=(3, 3, 3), padding=(1, 1, 1)),# nn.ReLU(inplace=True),# nn.Conv3d(512, 512, kernel_size=(3, 3, 3), padding=(1, 1, 1)),# nn.ReLU(inplace=True),# nn.Conv3d(512, 512, kernel_size=(3, 3, 3), padding=(1, 1, 1)),# nn.ReLU(inplace=True),# nn.MaxPool3d(kernel_size=(2, 2, 2), stride=(2, 2, 2)),)self.classifier = nn.Sequential(nn.Linear(512 * 8 * 8 * 1, 4096),nn.ReLU(True),nn.Linear(4096, 4096),nn.ReLU(True),nn.Linear(4096, out_channels),nn.Sigmoid())def forward(self, x):x = self.features(x)# x = x.view(x.size(0), -1)# x = self.classifier(x)return x# 测试代码
# if __name__ == '__main__':
#     x = torch.ones([2, 4, 256, 256, 32])
#     model = CustomVGG3D(in_channels=4, out_channels=1)
#     f = model(x)
#     print(f)

02 论文下载

Very deep convolutional neural network based image classification using small training sample size
arXiv: VERY DEEP CONVOLUTIONAL NETWORKS FOR LARGE-SCALE IMAGE RECOGNITION

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com