summaryrefslogtreecommitdiff
path: root/text_recognizer/networks/convnext/residual.py
blob: 3f4439040a32ed4bbcfffa0bccb1a6a64d3e0b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
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