summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--text_recognizer/networks/conv_transformer.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/text_recognizer/networks/conv_transformer.py b/text_recognizer/networks/conv_transformer.py
index d2ab8ea..ddf3b2e 100644
--- a/text_recognizer/networks/conv_transformer.py
+++ b/text_recognizer/networks/conv_transformer.py
@@ -1,6 +1,7 @@
"""Base network module."""
from typing import Optional, Tuple, Type
+import torch
from torch import Tensor, nn
from text_recognizer.networks.transformer.decoder import Decoder
@@ -108,6 +109,9 @@ class ConvTransformer(nn.Module):
trg = self.token_embedding(trg)
trg += self.token_pos_embedding(trg)
out = self.decoder(x=trg, context=src, input_mask=trg_mask)
+ logits = (
+ out @ torch.transpose(self.token_embedding.weight.to(trg.dtype), 0, 1)
+ ).float()
logits = self.to_logits(out) # [B, Sy, C]
logits = logits.permute(0, 2, 1) # [B, C, Sy]
return logits