def __init__(self, output_size, filter_size=5): super(network, self).__init__() size = filter_size bias = True self.conv1 = nn.Sequential( nn.Conv3d(1, 64, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.Conv3d(64, 64, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.BatchNorm3d(64)) self.conv2 = nn.Sequential( nn.Conv3d(64, 128, kernel_size=size, padding=size//2, stride=2, bias=bias), nn.ReLU(inplace=True), nn.Conv3d(128, 128, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.BatchNorm3d(128)) self.conv3 = nn.Sequential( nn.Conv3d(128, 256, kernel_size=size, padding=size//2, stride=2, bias=bias), nn.ReLU(inplace=True), nn.Conv3d(256, 256, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.BatchNorm3d(256)) self.up1 = nn.Sequential( nn.Upsample(scale_factor=2, mode="nearest"), nn.Conv3d(256, 128, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True)) self.merge1 = Merge() self.conv4 = nn.Sequential( nn.Conv3d(256, 128, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.Conv3d(128, 128, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.BatchNorm3d(128)) self.up2 = nn.Sequential( nn.Upsample(scale_factor=2, mode="nearest"), nn.Conv3d(128, 64, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True)) self.merge2 = Merge() self.conv5 = nn.Sequential( nn.Conv3d(128, 64, kernel_size=size, padding=size // 2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.Conv3d(64, 64, kernel_size=size, padding=size//2, stride=1, bias=bias), nn.ReLU(inplace=True), nn.BatchNorm3d(64)) self.conv_final = nn.Conv3d(64, output_size, kernel_size=1, padding=0, stride=1, bias=bias)
def __init__(self, output_size, filter_size=5): super(network, self).__init__() size = filter_size common_params = { 'radial_window': partial(basis_kernels.gaussian_window_fct_convenience_wrapper, mode='compromise', border_dist=0, sigma=0.6), 'batch_norm_momentum': 0.01, } features = [ (1, ), # (12, 12, 12), # (24, 24, 24), # (48, 48, 48), # (24, 24, 24), # (12, 12, 12), (8, 8, 8, 4), (16, 16, 16, 8), (32, 32, 32, 16), (16, 16, 16, 8), (8, 8, 8, 4), (output_size, ) ] # TODO: do padding using ReplicationPad3d? # TODO: on validation - use overlapping patches and only use center of patch self.conv1 = nn.Sequential( GatedBlock(features[0], features[1], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params), GatedBlock(features[1], features[1], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.conv2 = nn.Sequential( GatedBlock(features[1], features[2], size=size, padding=size // 2, stride=2, activation=(F.relu, F.sigmoid), normalization="instance", **common_params), GatedBlock(features[2], features[2], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.conv3 = nn.Sequential( GatedBlock(features[2], features[3], size=size, padding=size // 2, stride=2, activation=(F.relu, F.sigmoid), normalization="instance", **common_params), GatedBlock(features[3], features[3], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.up1 = nn.Sequential( nn.Upsample(scale_factor=2, mode="nearest"), GatedBlock(features[3], features[4], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.merge1 = Merge() self.conv4 = nn.Sequential( GatedBlock(features[3], features[4], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params), GatedBlock(features[4], features[4], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.up2 = nn.Sequential( nn.Upsample(scale_factor=2, mode="nearest"), GatedBlock(features[4], features[5], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.merge2 = Merge() self.conv5 = nn.Sequential( GatedBlock(features[4], features[5], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params), GatedBlock(features[5], features[5], size=size, padding=size // 2, stride=1, activation=(F.relu, F.sigmoid), normalization="instance", **common_params)) self.conv_final = GatedBlock(features[5], features[6], size=1, padding=0, stride=1, activation=None, normalization=None, **common_params)