diff options
Diffstat (limited to 'text_recognizer')
-rw-r--r-- | text_recognizer/networks/conformer/conformer.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/text_recognizer/networks/conformer/conformer.py b/text_recognizer/networks/conformer/conformer.py new file mode 100644 index 0000000..d56955e --- /dev/null +++ b/text_recognizer/networks/conformer/conformer.py @@ -0,0 +1,17 @@ +"""Conformer module.""" +from copy import deepcopy + +from torch import nn, Tensor + +from text_recognizer.networks.conformer.block import ConformerBlock + + +class Conformer(nn.Module): + def __init__(self, block: ConformerBlock, depth: int) -> None: + super().__init__() + self.blocks = nn.ModuleList([deepcopy(block) for _ in range(depth)]) + + def forward(self, x: Tensor) -> Tensor: + for fn in self.blocks: + x = fn(x) + return x |