加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
net.py 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
ZHUOYA ZHOU 提交于 2022-10-06 17:56 . Add files via upload
#coding:utf8
# =============================================================================
import torch
from torch import nn
class simpleNet5(nn.Module):
def __init__(self):
super(simpleNet5, self).__init__()
self.conv1 = nn.Sequential(
nn.Conv2d(3, 32, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(32),
nn.ReLU(True),
)
self.conv2 = nn.Sequential(
nn.Conv2d(32, 64, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(64),
nn.ReLU(True),
)
self.conv3 = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(128),
nn.ReLU(True),
)
self.conv4 = nn.Sequential(
nn.Conv2d(128, 256, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(256),
nn.ReLU(True),
)
self.conv5 = nn.Sequential(
nn.Conv2d(256, 512, kernel_size=3, stride=2, padding=1),
nn.BatchNorm2d(512),
nn.ReLU(True),
)
self.deconv1 = nn.Sequential(
nn.ConvTranspose2d(512, 256, 3, 2, 1, 1),
nn.BatchNorm2d(256),
nn.ReLU(True)
)
self.deconv2 = nn.Sequential(
nn.ConvTranspose2d(256, 128, 3, 2, 1, 1),
nn.BatchNorm2d(128),
nn.ReLU(True)
)
self.deconv3 = nn.Sequential(
nn.ConvTranspose2d(128, 64, 3, 2, 1, 1),
nn.BatchNorm2d(64),
nn.ReLU(True)
)
self.deconv4 = nn.Sequential(
nn.ConvTranspose2d(64, 32, 3, 2, 1, 1),
nn.BatchNorm2d(32),
nn.ReLU(True)
)
self.deconv5 = nn.Sequential(
nn.ConvTranspose2d(32, 8, 3, 2, 1, 1),
nn.BatchNorm2d(8),
nn.ReLU(True)
)
self.classifier = nn.Conv2d(8, 2, kernel_size=1)
def forward(self, x):
out = self.conv1(x)
out = self.conv2(out)
out = self.conv3(out)
out = self.conv4(out)
out = self.conv5(out)
out = self.deconv1(out)
out = self.deconv2(out)
out = self.deconv3(out)
out = self.deconv4(out)
out = self.deconv5(out)
out = self.classifier(out)
return out
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化