Segnet论文阅读笔记
代码参考:
SegNet From Scratch Using PyTorch | by Nikdenof | Medium
网络结构

编码器
CNNBlock
蓝色层:Conv+Batch Normalisation+ReLU
- cov:k=3,p=1,s=1, out channel=2*in_channel
import torch
import torch.nn as nn
class ConvBNReLU(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, padding=1):
super(ConvBNReLU, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding)
self.bn = nn.BatchNorm2d(out_channels)
self.relu = nn.ReLU(inplace=True)
def forward(self, x):
x = self.conv(x) # Apply convolution
x = self.bn(x) # Apply batch normalization
x = self.relu(x) # Apply ReLU activation
return x
绿色:池化
nn.MaxPool2d(kernek_size=2,stride=2,return_indices=True)
这里的return indices=True是为了后续的池化索引。
Encoder Block
class EncoderBlock(nn.Module):
def __init__(self, in_c, out_c, depth=2, kernel_size=3, padding=1) -> None:

最低0.47元/天 解锁文章
612

被折叠的 条评论
为什么被折叠?



