diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-05 21:21:14 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-05 21:21:14 +0200 |
commit | f8b8cc5b1a953744e7e0fed67d0764195eded9af (patch) | |
tree | b18ae199ced58191640929e767ecf356dec68b19 /text_recognizer/networks/conformer | |
parent | 6023d1254d6003233e52e943cd54fc9dece641f6 (diff) |
Add conformer
Diffstat (limited to 'text_recognizer/networks/conformer')
-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 |