Public Member Functions | Public Attributes | List of all members
model.UnetCollection Class Reference
Inheritance diagram for model.UnetCollection:

Public Member Functions

def __init__ (self, in_channels=1, out_channels=1)
 
def forward (self, conv1)
 
def single_conv_in (self, in_channels, out_channels, kernel_size, padding=1)
 
def single_conv_out (self, in_channels, out_channels, kernel_size, padding=1)
 
def conv_block (self, in_channels, out_channels, kernel_size, padding=[(1, 1))
 
def down_conv (self, in_channels, out_channels, kernel_size, stride)
 
def up_conv (self, in_channels, out_channels, kernel_size, stride, output_padding=0)
 

Public Attributes

 conv_in
 
 convs1_L
 
 down_conv1
 
 convs2_L
 
 down_conv2
 
 convs3_L
 
 down_conv3
 
 convs4_L
 
 down_conv_bottom
 
 convs_bottom
 
 up_conv_bottom
 
 convs4_R
 
 up_conv1
 
 convs3_R
 
 up_conv2
 
 convs2_R
 
 up_conv3
 
 convs1_R
 
 conv_out
 

Detailed Description

Definition at line 106 of file model.py.

Constructor & Destructor Documentation

def model.UnetCollection.__init__ (   self,
  in_channels = 1,
  out_channels = 1 
)

Definition at line 107 of file model.py.

107  def __init__(self, in_channels=1, out_channels=1):
108  super(UnetCollection, self).__init__()
109 
110  self.conv_in = self.single_conv_in(1, 4, 3)
111  self.convs1_L = self.conv_block(4, 4 ,3)
112  self.down_conv1 = self.down_conv(4, 8, 3, 3)
113  self.convs2_L = self.conv_block(8, 8, 3)
114  self.down_conv2 = self.down_conv(8, 16, 3, 3)
115  self.convs3_L = self.conv_block(16, 16, 3, padding=[(0,0), (0,0)])
116  self.down_conv3 = self.down_conv(16, 32, 3, 3)
117  self.convs4_L = self.conv_block(32, 32, 3, padding=[(0,0),(0,0)])
118 
119  self.down_conv_bottom = self.down_conv(32, 64, 3, 3)
120  self.convs_bottom = self.conv_block(64, 64, 3, padding=[(1,1),(1,1)])
121  self.up_conv_bottom = self.up_conv(64, 32, 3, 3, output_padding=(0,0))
122 
123  self.convs4_R = self.conv_block(32*2, 32, 3, padding=[(2,2),(2,2)])
124  self.up_conv1 = self.up_conv(32, 16, 3, 3, output_padding=(2,1))
125  self.convs3_R = self.conv_block(16*2, 16, 3, padding=[(2,2),(2,2)])
126  self.up_conv2 = self.up_conv(16, 8, 3, 3, output_padding=(2,1))
127  self.convs2_R = self.conv_block(8*2, 8, 3)
128  self.up_conv3 = self.up_conv(8, 4, 3, 3, output_padding=(0,0))
129  self.convs1_R = self.conv_block(4*2, 4, 3)
130  self.conv_out = self.single_conv_out(4, 1, 3)
131 
def down_conv(self, in_channels, out_channels, kernel_size, stride)
Definition: model.py:182
def single_conv_out(self, in_channels, out_channels, kernel_size, padding=1)
Definition: model.py:163
def conv_block(self, in_channels, out_channels, kernel_size, padding=[(1, 1))
Definition: model.py:171
def __init__(self, in_channels=1, out_channels=1)
Definition: model.py:107
def single_conv_in(self, in_channels, out_channels, kernel_size, padding=1)
Definition: model.py:157
def up_conv(self, in_channels, out_channels, kernel_size, stride, output_padding=0)
Definition: model.py:190

Member Function Documentation

def model.UnetCollection.conv_block (   self,
  in_channels,
  out_channels,
  kernel_size,
  padding = [(1,1) 
)

Definition at line 171 of file model.py.

171  def conv_block(self, in_channels, out_channels, kernel_size, padding=[(1,1),(1,1)]):
172  conv_block = nn.Sequential(
173  nn.BatchNorm2d(in_channels),
174  nn.ReLU(),
175  nn.Conv2d(in_channels, out_channels, kernel_size, padding=padding[0]),
176  nn.BatchNorm2d(out_channels),
177  nn.ReLU(),
178  nn.Conv2d(out_channels, out_channels, kernel_size, padding=padding[1]))
179 
180  return conv_block
181 
def conv_block(self, in_channels, out_channels, kernel_size, padding=[(1, 1))
Definition: model.py:171
def model.UnetCollection.down_conv (   self,
  in_channels,
  out_channels,
  kernel_size,
  stride 
)

Definition at line 182 of file model.py.

182  def down_conv(self, in_channels, out_channels, kernel_size, stride):
183  down_conv = nn.Sequential(
184  nn.BatchNorm2d(in_channels),
185  nn.ReLU(),
186  nn.Conv2d(in_channels, out_channels, kernel_size, stride))
187 
188  return down_conv
189 
def down_conv(self, in_channels, out_channels, kernel_size, stride)
Definition: model.py:182
def model.UnetCollection.forward (   self,
  conv1 
)

Definition at line 132 of file model.py.

132  def forward(self, conv1):
133  conv1 = self.conv_in(conv1)
134  conv1 = self.convs1_L(conv1)
135  conv2 = self.down_conv1(conv1)
136  conv2 = self.convs2_L(conv2)
137  conv3 = self.down_conv2(conv2)
138  conv3 = self.convs3_L(conv3)
139  conv4 = self.down_conv3(conv3)
140  conv4 = self.convs4_L(conv4)
141 
142  conv_bottom = self.down_conv_bottom(conv4)
143  conv_bottom = self.convs_bottom(conv_bottom)
144  conv_bottom = self.up_conv_bottom(conv_bottom)
145 
146  conv4 = self.convs4_R(torch.cat([conv_bottom, conv4], 1))
147  conv4 = self.up_conv1(conv4)
148  conv3 = self.convs3_R(torch.cat([conv4, conv3], 1))
149  conv3 = self.up_conv2(conv3)
150  conv2 = self.convs2_R(torch.cat([conv3, conv2], 1))
151  conv2 = self.up_conv3(conv2)
152  conv1 = self.convs1_R(torch.cat([conv2, conv1], 1))
153  conv1 = self.conv_out(conv1)
154 
155  return conv1
156 
def forward(self, conv1)
Definition: model.py:132
def model.UnetCollection.single_conv_in (   self,
  in_channels,
  out_channels,
  kernel_size,
  padding = 1 
)

Definition at line 157 of file model.py.

157  def single_conv_in(self, in_channels, out_channels, kernel_size, padding=1):
158  conv = nn.Sequential(
159  nn.Conv2d(in_channels, out_channels, kernel_size, padding=padding))
160 
161  return conv
162 
def single_conv_in(self, in_channels, out_channels, kernel_size, padding=1)
Definition: model.py:157
def model.UnetCollection.single_conv_out (   self,
  in_channels,
  out_channels,
  kernel_size,
  padding = 1 
)

Definition at line 163 of file model.py.

163  def single_conv_out(self, in_channels, out_channels, kernel_size, padding=1):
164  conv = nn.Sequential(
165  nn.BatchNorm2d(in_channels),
166  nn.ReLU(),
167  nn.Conv2d(in_channels, out_channels, kernel_size, padding=padding))
168 
169  return conv
170 
def single_conv_out(self, in_channels, out_channels, kernel_size, padding=1)
Definition: model.py:163
def model.UnetCollection.up_conv (   self,
  in_channels,
  out_channels,
  kernel_size,
  stride,
  output_padding = 0 
)

Definition at line 190 of file model.py.

190  def up_conv(self, in_channels, out_channels, kernel_size, stride, output_padding=0):
191  up_conv = nn.Sequential(
192  nn.BatchNorm2d(in_channels),
193  nn.ReLU(),
194  nn.ConvTranspose2d(in_channels, out_channels, kernel_size, stride, output_padding=output_padding))
195 
196  return up_conv
197 
198 
def up_conv(self, in_channels, out_channels, kernel_size, stride, output_padding=0)
Definition: model.py:190

Member Data Documentation

model.UnetCollection.conv_in

Definition at line 110 of file model.py.

model.UnetCollection.conv_out

Definition at line 130 of file model.py.

model.UnetCollection.convs1_L

Definition at line 111 of file model.py.

model.UnetCollection.convs1_R

Definition at line 129 of file model.py.

model.UnetCollection.convs2_L

Definition at line 113 of file model.py.

model.UnetCollection.convs2_R

Definition at line 127 of file model.py.

model.UnetCollection.convs3_L

Definition at line 115 of file model.py.

model.UnetCollection.convs3_R

Definition at line 125 of file model.py.

model.UnetCollection.convs4_L

Definition at line 117 of file model.py.

model.UnetCollection.convs4_R

Definition at line 123 of file model.py.

model.UnetCollection.convs_bottom

Definition at line 120 of file model.py.

model.UnetCollection.down_conv1

Definition at line 112 of file model.py.

model.UnetCollection.down_conv2

Definition at line 114 of file model.py.

model.UnetCollection.down_conv3

Definition at line 116 of file model.py.

model.UnetCollection.down_conv_bottom

Definition at line 119 of file model.py.

model.UnetCollection.up_conv1

Definition at line 124 of file model.py.

model.UnetCollection.up_conv2

Definition at line 126 of file model.py.

model.UnetCollection.up_conv3

Definition at line 128 of file model.py.

model.UnetCollection.up_conv_bottom

Definition at line 121 of file model.py.


The documentation for this class was generated from the following file: