文章目录
文章目录
- 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