- 1、本文档共7页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[pytorch]医学图像之肝脏语义分割 (训练+预测代码)
⼀⼀ ,,Unet结结构构 ::
结合上图的Unet结构, ytorch的unet代码如下 :
unet. y :
import torch.nn as nn
import torch
from torch import autograd
class DoubleConv(nn.Module) :
def init (self, in ch, out ch) :
super(DoubleConv, self). init ()
self.conv = nn.Sequential(
nn.Conv2d(in ch, out ch, 3, padding=1),
nn.BatchNorm2d(out ch),
nn.ReLU(inplace=True),
nn.Conv2d(out ch, out ch, 3, padding=1),
nn.BatchNorm2d(out ch),
nn.ReLU(inplace=True)
)
def forward(self, input) :
return self.conv(input)
class Unet(nn.Module) :
def init (self, in ch, out ch) :
super(Unet, self). init ()
self.conv 1 = DoubleConv(in ch, 64)
self.pool1 = nn.MaxPool2d(2)
self.conv2 = DoubleConv(64, 128)
self.pool2 = nn.MaxPool2d(2)
self.conv3 = DoubleConv(128, 256)
self.pool3 = nn.MaxPool2d(2)
self.conv4 = DoubleConv(256, 512)
self.pool4 = nn.MaxPool2d(2)
self.conv5 = DoubleConv(512, 1024)
self.up6 = nn.ConvTranspose2d(1024, 512, 2, stride=2)
self.conv6 = DoubleConv(1024, 512)
self.up7 = nn.ConvTranspose2d(512, 256, 2, stride=2)
self.conv7 = DoubleConv(512, 256)
self.up8 = nn.ConvTranspose2d(256, 128, 2, stride=2)
self.up8 = nn.ConvTranspose2d(256, 128, 2, stride=2)
self.conv8 = DoubleConv(256, 128)
self.up9 = nn.ConvTranspose2d(128, 64, 2, stride=2)
self.conv9 = DoubleConv(128, 64)
self.conv 10 = nn.Conv2d(64, out ch, 1)
def forward(self, x) :
c1 = self.conv 1(x)
p1 = self.pool1(c1)
c2 = self.conv2(p1)
p2 = self.pool2(c2)
文档评论(0)