MCPcopy Create free account
hub / github.com/CompVis/diff2flow / FeedForward

Class FeedForward

diff2flow/models/unet/attention.py:57–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56
57class FeedForward(nn.Module):
58 def __init__(self, dim, dim_out=None, mult=4, glu=False, dropout=0.):
59 super().__init__()
60 inner_dim = int(dim * mult)
61 dim_out = default(dim_out, dim)
62 project_in = nn.Sequential(
63 nn.Linear(dim, inner_dim),
64 nn.GELU()
65 ) if not glu else GEGLU(dim, inner_dim)
66
67 self.net = nn.Sequential(
68 project_in,
69 nn.Dropout(dropout),
70 nn.Linear(inner_dim, dim_out)
71 )
72
73 def forward(self, x):
74 return self.net(x)
75
76
77def zero_module(module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected