记录pytorch怎么搭建网络,看起来更舒服
首先定义一个block
class myBlock(nn.module):
def __init__(self,in_channel,out_channel,····):
super(myBlock,self).__init__()
·······
def forward(self,x):
·······
然后直接定义网络
class net(nn.module):
def __init__(self):
super(net,self).__init__()
self.branch=nn.Sequential(myBlock(1,2),
myBlock(2,4))
·······
def forward(self,x):
x= self.branch(x)
return x