def forward(self, tensorFirst, tensorSecond): tensorJoin = torch.cat([tensorFirst, tensorSecond], 1) tensorConv1 = self.moduleConv1(tensorJoin) tensorPool1 = self.modulePool1(tensorConv1) tensorConv2 = self.moduleConv2(tensorPool1) tensorPool2 = self.modulePool2(tensorConv2) tensorConv3 = self.moduleConv3(tensorPool2) tensorPool3 = self.modulePool3(tensorConv3) tensorConv4 = self.moduleConv4(tensorPool3) tensorPool4 = self.modulePool4(tensorConv4) tensorConv5 = self.moduleConv5(tensorPool4) tensorPool5 = self.modulePool5(tensorConv5) tensorDeconv5 = self.moduleDeconv5(tensorPool5) tensorUpsample5 = self.moduleUpsample5(tensorDeconv5) tensorCombine = tensorUpsample5 + tensorConv5 tensorDeconv4 = self.moduleDeconv4(tensorCombine) tensorUpsample4 = self.moduleUpsample4(tensorDeconv4) tensorCombine = tensorUpsample4 + tensorConv4 tensorDeconv3 = self.moduleDeconv3(tensorCombine) tensorUpsample3 = self.moduleUpsample3(tensorDeconv3) tensorCombine = tensorUpsample3 + tensorConv3 tensorDeconv2 = self.moduleDeconv2(tensorCombine) tensorUpsample2 = self.moduleUpsample2(tensorDeconv2) tensorCombine = tensorUpsample2 + tensorConv2 tensorDot1 = sepconv.FunctionSepconv()( self.modulePad(tensorFirst), self.moduleVertical1(tensorCombine), self.moduleHorizontal1(tensorCombine)) tensorDot2 = sepconv.FunctionSepconv()( self.modulePad(tensorSecond), self.moduleVertical2(tensorCombine), self.moduleHorizontal2(tensorCombine)) return tensorDot1 + tensorDot2
def forward(self, tensorFirst, tensorSecond): tensorConv1 = self.moduleConv1(torch.cat([ tensorFirst, tensorSecond ], 1)) tensorConv2 = self.moduleConv2(torch.nn.functional.avg_pool2d(input=tensorConv1, kernel_size=2, stride=2, count_include_pad=False)) tensorConv3 = self.moduleConv3(torch.nn.functional.avg_pool2d(input=tensorConv2, kernel_size=2, stride=2, count_include_pad=False)) tensorConv4 = self.moduleConv4(torch.nn.functional.avg_pool2d(input=tensorConv3, kernel_size=2, stride=2, count_include_pad=False)) tensorConv5 = self.moduleConv5(torch.nn.functional.avg_pool2d(input=tensorConv4, kernel_size=2, stride=2, count_include_pad=False)) tensorDeconv5 = self.moduleUpsample5(self.moduleDeconv5(torch.nn.functional.avg_pool2d(input=tensorConv5, kernel_size=2, stride=2, count_include_pad=False))) tensorDeconv4 = self.moduleUpsample4(self.moduleDeconv4(tensorDeconv5 + tensorConv5)) tensorDeconv3 = self.moduleUpsample3(self.moduleDeconv3(tensorDeconv4 + tensorConv4)) tensorDeconv2 = self.moduleUpsample2(self.moduleDeconv2(tensorDeconv3 + tensorConv3)) tensorCombine = tensorDeconv2 + tensorConv2 tensorFirst = torch.nn.functional.pad(input=tensorFirst, pad=[ int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)) ], mode='replicate') tensorSecond = torch.nn.functional.pad(input=tensorSecond, pad=[ int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)) ], mode='replicate') tensorDot1 = sepconv.FunctionSepconv(tensorInput=tensorFirst, tensorVertical=self.moduleVertical1(tensorCombine), tensorHorizontal=self.moduleHorizontal1(tensorCombine)) tensorDot2 = sepconv.FunctionSepconv(tensorInput=tensorSecond, tensorVertical=self.moduleVertical2(tensorCombine), tensorHorizontal=self.moduleHorizontal2(tensorCombine)) return tensorDot1 + tensorDot2
def forward(self, tensorFirst, tensorSecond): tensorJoin = torch.cat([tensorFirst, tensorSecond], 1) tensorConv1 = self.moduleConv1(tensorJoin) tensorPool1 = self.modulePool1(tensorConv1) tensorConv2 = self.moduleConv2(tensorPool1) tensorPool2 = self.modulePool2(tensorConv2) tensorConv3 = self.moduleConv3(tensorPool2) tensorPool3 = self.modulePool3(tensorConv3) tensorConv4 = self.moduleConv4(tensorPool3) tensorPool4 = self.modulePool4(tensorConv4) tensorConv5 = self.moduleConv5(tensorPool4) tensorPool5 = self.modulePool5(tensorConv5) tensorDeconv5 = self.moduleDeconv5(tensorPool5) tensorUpsample5 = self.moduleUpsample5(tensorDeconv5) tensorCombine = tensorUpsample5 + tensorConv5 tensorDeconv4 = self.moduleDeconv4(tensorCombine) tensorUpsample4 = self.moduleUpsample4(tensorDeconv4) tensorCombine = tensorUpsample4 + tensorConv4 tensorDeconv3 = self.moduleDeconv3(tensorCombine) tensorUpsample3 = self.moduleUpsample3(tensorDeconv3) tensorCombine = tensorUpsample3 + tensorConv3 tensorDeconv2 = self.moduleDeconv2(tensorCombine) tensorUpsample2 = self.moduleUpsample2(tensorDeconv2) tensorCombine = tensorUpsample2 + tensorConv2 tensorFirst = torch.nn.functional.pad(input=tensorFirst, pad=[ int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)) ], mode='replicate') tensorSecond = torch.nn.functional.pad(input=tensorSecond, pad=[ int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)), int(math.floor(51 / 2.0)) ], mode='replicate') tensorDot1 = sepconv.FunctionSepconv( tensorInput=tensorFirst, tensorVertical=self.moduleVertical1(tensorCombine), tensorHorizontal=self.moduleHorizontal1(tensorCombine)) tensorDot2 = sepconv.FunctionSepconv( tensorInput=tensorSecond, tensorVertical=self.moduleVertical2(tensorCombine), tensorHorizontal=self.moduleHorizontal2(tensorCombine)) return tensorDot1 + tensorDot2