summaryrefslogtreecommitdiff
path: root/text_recognizer/networks/convnext/residual.py
blob: 8e76ae9ce8ebe887f68903aeaeb474bb7d8623ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
"""Generic residual layer."""
from typing import Callable

from torch import Tensor, nn


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