MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / MHCA

Class MHCA

dmidas/backbones/next_vit.py:130–148  ·  view source on GitHub ↗

Multi-Head Convolutional Attention

Source from the content-addressed store, hash-verified

128
129
130class MHCA(nn.Module):
131 """
132 Multi-Head Convolutional Attention
133 """
134 def __init__(self, out_channels, head_dim):
135 super(MHCA, self).__init__()
136 norm_layer = partial(nn.BatchNorm2d, eps=NORM_EPS)
137 self.group_conv3x3 = nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=1,
138 padding=1, groups=out_channels // head_dim, bias=False)
139 self.norm = norm_layer(out_channels)
140 self.act = nn.ReLU(inplace=True)
141 self.projection = nn.Conv2d(out_channels, out_channels, kernel_size=1, bias=False)
142
143 def forward(self, x):
144 out = self.group_conv3x3(x)
145 out = self.norm(out)
146 out = self.act(out)
147 out = self.projection(out)
148 return out
149
150
151class Mlp(nn.Module):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected