MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / forward

Method forward

lib/Modules.py:84–95  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

82 self.softmax = nn.Softmax(dim=-1)
83
84 def forward(self, x):
85 m_batchsize, C, height, width = x.size()
86 proj_query = self.query_conv(x).view(m_batchsize, -1, width * height).permute(0, 2, 1)
87 proj_key = self.key_conv(x).view(m_batchsize, -1, width * height)
88 energy = torch.bmm(proj_query, proj_key)
89 attention = self.softmax(energy)
90 proj_value = self.value_conv(x).view(m_batchsize, -1, width * height)
91 out = torch.bmm(proj_value, attention.permute(0, 2, 1))
92 out = out.view(m_batchsize, C, height, width)
93 out = self.gamma * out + x
94
95 return out
96
97
98"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected