diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-09-13 19:07:53 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-09-13 19:07:53 +0200 |
commit | 9732617e402a5152ba822eb1459d6ff776aba15c (patch) | |
tree | 69cd4d4895f486bf41d20e7a74cad683ebd64294 /text_recognizer/networks/convnext/residual.py | |
parent | 3c411a90422af3e97f5b71402dcf897642b24db7 (diff) |
Add convnext module
Diffstat (limited to 'text_recognizer/networks/convnext/residual.py')
-rw-r--r-- | text_recognizer/networks/convnext/residual.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/text_recognizer/networks/convnext/residual.py b/text_recognizer/networks/convnext/residual.py new file mode 100644 index 0000000..3f44390 --- /dev/null +++ b/text_recognizer/networks/convnext/residual.py @@ -0,0 +1,12 @@ +"""Generic residual layer.""" +from typing import Callable +from torch import nn, Tensor + + +class Residual(nn.Module): + def __init__(self, fn: Callable) -> None: + super().__init__() + self.fn = fn + + def forward(self, x: Tensor) -> Tensor: + return self.fn(x) + x |