blob: d012b812e845e1ebace693d1557332fea1bdf664 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
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) -> Tensor:
return self.fn(x, **kwargs) * self.scale
|