summaryrefslogtreecommitdiff
path: root/text_recognizer/network/convnext/residual.py
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2023-09-03 22:54:09 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2023-09-03 22:54:09 +0200
commit1732ed564a738a42c1bf6e8127ae810f5658cb06 (patch)
tree8d7f67793fec820850b4f8fd92f762f7f5e4b9f6 /text_recognizer/network/convnext/residual.py
parent53cfc21cffa4e877ad0959170b47b690d2fdb40f (diff)
Revert "Delete convnext"
This reverts commit 7239bce214607c70a7a91358586f265b2f74de7b.
Diffstat (limited to 'text_recognizer/network/convnext/residual.py')
-rw-r--r--text_recognizer/network/convnext/residual.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/text_recognizer/network/convnext/residual.py b/text_recognizer/network/convnext/residual.py
new file mode 100644
index 0000000..dfc2847
--- /dev/null
+++ b/text_recognizer/network/convnext/residual.py
@@ -0,0 +1,16 @@
+"""Generic residual layer."""
+from typing import Callable
+
+from torch import Tensor, nn
+
+
+class Residual(nn.Module):
+ """Residual layer."""
+
+ def __init__(self, fn: Callable) -> None:
+ super().__init__()
+ self.fn = fn
+
+ def forward(self, x: Tensor) -> Tensor:
+ """Applies residual fn."""
+ return self.fn(x) + x