MCPcopy Create free account
hub / github.com/csxmli2016/MARCONetPlusPlus / forward

Method forward

networks/transocr_arch.py:296–310  ·  view source on GitHub ↗
(self, text, conv_feature)

Source from the content-addressed store, hash-verified

294 self.mul_layernorm3 = LayerNorm(features=1024)
295
296 def forward(self, text, conv_feature):
297 text_max_length = text.shape[1]
298 mask = subsequent_mask(text_max_length).cuda()
299
300 result = text
301 result = self.mul_layernorm1(result + self.mask_multihead(result, result, result, mask=mask)[0])
302
303 b, c, h, w = conv_feature.shape
304 conv_feature = conv_feature.view(b, c, h * w).permute(0, 2, 1).contiguous()
305 word_image_align, attention_map = self.multihead(result, conv_feature, conv_feature, mask=None)
306 result = self.mul_layernorm2(result + word_image_align)
307
308 result = self.mul_layernorm3(result + self.pff(result))
309
310 return result, attention_map
311
312
313class TransformerOCR(nn.Module):

Callers

nothing calls this directly

Calls 1

subsequent_maskFunction · 0.85

Tested by

no test coverage detected