标题 #使用ASPP处理3D体数据
```python-pytorch
import torch
import torch.nn as nn
class ASPP(nn.Module):
def __init__(self, in_channel, out_channel):
super(ASPP, self).__init__()
self.mean = nn.AdaptiveAvgPool3d((1, 1, 1))
self.conv = nn.Conv3d(in_channel, out_channel, 1, 1)
self.Upsample = nn.Upsample(size=(8, 8, 8), mode='trilinear')
self.atrous_block1 = nn.Conv3d(in_channel, out_channel, 1, 1)
self.atrous_block6 = nn.Conv3d(in_channel, out_channel, 3, 1, padding=6, dilation=6)
self.atrous_block12 = nn.Conv3d(in_channel, out_channel, 3, 1, padding=12, dilation=12)
self.atrous_block18 = nn.Conv3d(in_channel, out_channel, 3, 1, padding=18, dilation=18)
self.conv_1x1_output = nn.Conv3d(out_channel * 6, out_channel, 1, 1)
self.dropout = nn.Dropout3d(0.5)
def forward(self, x):
size = x.shape[2:]
image_features = self.mean(x)
image_features = self.conv(image_features)
image_features = self.Upsample(image_features)
atrous_block1 = self.atrous_block1(x)
atrous_block6 = self.atrous_block6(x)
atrous_block12 = self.atrous_block12(x)
atrous_block18 = self.atrous_block18(x)
net = self.conv_1x1_output(torch.cat([x, image_features, atrous_block1, atrous_block6, atrous_block12, atrous_block18], dim=1))
net = self.dropout(net)
return net
ASPP的原理不做太多的介绍,不懂的同学参考:
https://blog.csdn.net/qq_36530992/article/details/102628455#comments_18044608
https://blog.csdn.net/qq_43534932/article/details/109253935