MCPcopy Create free account
hub / github.com/BIT-MCS/DRL-eFresh / spatial_softmax

Function spatial_softmax

utils/spatial_att_github.py:226–234  ·  view source on GitHub ↗
(A)

Source from the content-addressed store, hash-verified

224
225
226def spatial_softmax(A):
227 # A: batch_size x h x w x d
228 b, h, w, d = A.size()
229 # Flatten A s.t. softmax is applied to each grid (not over queries)
230 A = A.reshape(b, h * w, d)
231 A = F.softmax(A, dim=1)
232 # Reshape A to original shape.
233 A = A.reshape(b, h, w, d)
234 return A
235
236
237def apply_alpha(A, V):

Callers 1

forwardMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected