MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / __init__

Method __init__

diffsynth/models/step1x_connector.py:25–58  ·  view source on GitHub ↗
(
        self,
        in_channels,
        hidden_channels=None,
        out_features=None,
        act_layer=nn.GELU,
        norm_layer=None,
        bias=True,
        drop=0.0,
        use_conv=False,
        device=None,
        dtype=None,
    )

Source from the content-addressed store, hash-verified

23 """MLP as used in Vision Transformer, MLP-Mixer and related networks"""
24
25 def __init__(
26 self,
27 in_channels,
28 hidden_channels=None,
29 out_features=None,
30 act_layer=nn.GELU,
31 norm_layer=None,
32 bias=True,
33 drop=0.0,
34 use_conv=False,
35 device=None,
36 dtype=None,
37 ):
38 super().__init__()
39 out_features = out_features or in_channels
40 hidden_channels = hidden_channels or in_channels
41 bias = (bias, bias)
42 drop_probs = (drop, drop)
43 linear_layer = partial(nn.Conv2d, kernel_size=1) if use_conv else nn.Linear
44
45 self.fc1 = linear_layer(
46 in_channels, hidden_channels, bias=bias[0], device=device, dtype=dtype
47 )
48 self.act = act_layer()
49 self.drop1 = nn.Dropout(drop_probs[0])
50 self.norm = (
51 norm_layer(hidden_channels, device=device, dtype=dtype)
52 if norm_layer is not None
53 else nn.Identity()
54 )
55 self.fc2 = linear_layer(
56 hidden_channels, out_features, bias=bias[1], device=device, dtype=dtype
57 )
58 self.drop2 = nn.Dropout(drop_probs[1])
59
60 def forward(self, x):
61 x = self.fc1(x)

Callers 8

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected