diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-01 23:11:05 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-06-01 23:11:05 +0200 |
commit | 729867b14754bffd98a3406b5d3a2eb9d09bc3bc (patch) | |
tree | d22fbe9a9aacd2b7e457f8af4b667c5c8d927d73 /text_recognizer/networks/conformer/scale.py | |
parent | db86cef2d308f58325278061c6aa177a535e7e03 (diff) |
WIP conformer
Diffstat (limited to 'text_recognizer/networks/conformer/scale.py')
-rw-r--r-- | text_recognizer/networks/conformer/scale.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/text_recognizer/networks/conformer/scale.py b/text_recognizer/networks/conformer/scale.py new file mode 100644 index 0000000..da736a3 --- /dev/null +++ b/text_recognizer/networks/conformer/scale.py @@ -0,0 +1,13 @@ +"""Scale layer.""" +from typing import Dict +from torch import nn, Tensor + + +class Scale(nn.Module): + def __init__(self, scale: float, fn: nn.Module) -> None: + super().__init__() + self.scale = scale + self.fn = fn + + def forward(self, x: Tensor, kwargs: Dict) -> Tensor: + return self.fn(x, **kwargs) * self.scale |