Esempio n. 1
0
 def __init__(self):
     super().__init__()
     self.relu = nn.ReLU()
     self.enc = resunet(10,
                        62,
                        block=HyperBottleneck,
                        relu=nn.ReLU(inplace=True),
                        layers=6,
                        ratio=-2,
                        vblks=[1, 1, 1, 1, 1, 1],
                        hblks=[3, 3, 3, 3, 3, 3],
                        scales=[-1, -1, -1, -1, -1, -1],
                        factors=[1, 1, 1, 1, 1, 1],
                        spatial=(64, 64))
     self.dec = resunet(10,
                        10,
                        block=HyperBottleneck,
                        relu=CappingRelu(),
                        layers=6,
                        ratio=-3,
                        vblks=[1, 1, 1, 1, 1, 1],
                        hblks=[0, 0, 0, 0, 0, 0],
                        scales=[-1, -1, -1, -1, -1, -1],
                        factors=[1, 1, 1, 1, 1, 1],
                        spatial=(64, 64),
                        final_normalized=True)
Esempio n. 2
0
 def test1D(self):
     net = resunet(1, 1, spatial=(32, ))
     net(th.rand(1, 1, 16))
     net = resunet(1, 1, spatial=(32, ), normalizor='instance')
     net(th.rand(1, 1, 16))
     net = resunet(1, 1, spatial=(32, ), normalizor='layer')
     net(th.rand(1, 1, 16))
Esempio n. 3
0
 def testCmplxHyp1D2(self):
     net = resunet(1,
                   1,
                   spatial=(32, ),
                   block=CmplxHyperBasic2,
                   ratio=2,
                   complex=True)
     net(th.rand(1, 1, 16, dtype=th.cfloat).view(1, 1, 16))
     net = resunet(1,
                   1,
                   spatial=(32, ),
                   block=CmplxHyperBottleneck2,
                   ratio=2,
                   complex=True)
     net(th.rand(1, 1, 16, dtype=th.cfloat).view(1, 1, 16))
Esempio n. 4
0
 def testCmplxHyp2D2(self):
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   block=CmplxHyperBasic2,
                   ratio=2,
                   complex=True)
     net(th.rand(1, 1, 32, 16, dtype=th.cfloat).view(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   block=CmplxHyperBottleneck2,
                   ratio=2,
                   complex=True)
     net(th.rand(1, 1, 32, 16, dtype=th.cfloat).view(1, 1, 32, 16))
Esempio n. 5
0
 def testHyp1D(self):
     net = resunet(1, 1, spatial=(32, ), block=HyperBasic)
     net(th.rand(1, 1, 16))
     net = resunet(1,
                   1,
                   spatial=(32, ),
                   normalizor='instance',
                   block=HyperBasic)
     net(th.rand(1, 1, 16))
     net = resunet(1,
                   1,
                   spatial=(32, ),
                   normalizor='layer',
                   block=HyperBasic)
     net(th.rand(1, 1, 16))
     net = resunet(1, 1, spatial=(32, ), block=HyperBottleneck)
     net(th.rand(1, 1, 16))
     net = resunet(1,
                   1,
                   spatial=(32, ),
                   normalizor='instance',
                   block=HyperBottleneck)
     net(th.rand(1, 1, 16))
     net = resunet(1,
                   1,
                   spatial=(32, ),
                   normalizor='layer',
                   block=HyperBottleneck)
     net(th.rand(1, 1, 16))
Esempio n. 6
0
 def test2D(self):
     resunet(1, 1, spatial=(16, 16))
     resunet(1, 1, spatial=(16, 32))
     resunet(1, 1, spatial=(32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]])
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='instance')
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='layer')
     net(th.rand(1, 1, 32, 16))
Esempio n. 7
0
    def __init__(self):
        super().__init__()

        self.relu = nn.ReLU(inplace=True)
        self.relu6 = nn.ReLU6(inplace=True)
        self.oconv = nn.Conv2d(20, 10, kernel_size=3, padding=1)
        self.dropout = nn.Dropout2d(p=0.5)

        self.enc = resunet(10,
                           160,
                           block=HyperBottleneck,
                           layers=6,
                           ratio=-1,
                           vblks=[1, 1, 1, 1, 1, 1],
                           hblks=[1, 1, 1, 1, 1, 1],
                           scales=[-1, -1, -1, -1, -1, -1],
                           factors=[1, 1, 1, 1, 1, 1],
                           spatial=(64, 64))
Esempio n. 8
0
 def testHyp3D2(self):
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   block=HyperBasic2)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='instance',
                   block=HyperBasic2)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='layer',
                   block=HyperBasic2)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   block=HyperBottleneck2)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='instance',
                   block=HyperBottleneck2)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='layer',
                   block=HyperBottleneck2)
     net(th.rand(1, 1, 4, 16, 32))
Esempio n. 9
0
 def testWP2D(self):
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   block=WarpBasicBlock,
                   attn=SELayer)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='instance',
                   block=WarpBasicBlock,
                   attn=WarpLayer)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='layer',
                   block=WarpBasicBlock,
                   attn=SELayer)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   block=WarpBottleneck,
                   attn=SELayer)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='instance',
                   block=WarpBottleneck,
                   attn=WarpLayer)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='layer',
                   block=WarpBottleneck,
                   attn=SELayer)
     net(th.rand(1, 1, 32, 16))
Esempio n. 10
0
 def testSE3D(self):
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   block=SEBasicBlock)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='instance',
                   block=SEBasicBlock)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='layer',
                   block=SEBasicBlock)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   block=SEBottleneck)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='instance',
                   block=SEBottleneck)
     net(th.rand(1, 1, 4, 16, 32))
     net = resunet(1,
                   1,
                   spatial=(4, 16, 32),
                   scales=[[0, -1, -1], [-1, -1, -1], [0, -1, -1],
                           [-1, -1, -1]],
                   normalizor='layer',
                   block=SEBottleneck)
     net(th.rand(1, 1, 4, 16, 32))
Esempio n. 11
0
 def testHyp2DGroupNorm(self):
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='group',
                   block=HyperBasic)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='group',
                   block=HyperBasic)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='group',
                   block=HyperBasic)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='group',
                   block=HyperBottleneck)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='group',
                   block=HyperBottleneck)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='group',
                   block=HyperBottleneck)
     net(th.rand(1, 1, 32, 16))
Esempio n. 12
0
 def testCmplxHyp2D(self):
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   block=CmplxHyperBasic)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='instance',
                   block=CmplxHyperBasic)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='layer',
                   block=CmplxHyperBasic)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   block=CmplxHyperBottleneck)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='instance',
                   block=CmplxHyperBottleneck)
     net(th.rand(1, 1, 32, 16))
     net = resunet(1,
                   1,
                   spatial=(32, 16),
                   scales=[[0, -1], [0, -1], [0, -1], [0, -1]],
                   normalizor='layer',
                   block=CmplxHyperBottleneck)
     net(th.rand(1, 1, 32, 16))