From 9732617e402a5152ba822eb1459d6ff776aba15c Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Tue, 13 Sep 2022 19:07:53 +0200 Subject: Add convnext module --- text_recognizer/networks/convnext/residual.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 text_recognizer/networks/convnext/residual.py (limited to 'text_recognizer/networks/convnext/residual.py') 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 -- cgit v1.2.3-70-g09d2