MCPcopy Create free account
hub / github.com/SooLab/CGFormer / forward

Method forward

model/layers.py:104–128  ·  view source on GitHub ↗

x: b, 512, 104, 104 text: b, 512

(self, x, text)

Source from the content-addressed store, hash-verified

102 self.txt = nn.Linear(text_dim, out_dim)
103
104 def forward(self, x, text):
105 '''
106 x: b, 512, 104, 104
107 text: b, 512
108 '''
109 x = self.vis(x) # Eq. 8
110
111 B, C, H, W = x.size()
112 # 1, b*256, 104, 104
113 x = x.reshape(1, B * C, H, W)
114 # txt: b, 1, (256*3*3 + 1) -> b, 1, 256, 3, 3 / b
115 text = self.txt(text) # Eq. 8
116
117 weight, bias = text[:, :-1], text[:, -1]
118 weight = weight.reshape(B, C, self.kernel_size, self.kernel_size)
119 # Conv2d - 1, b*256, 104, 104 -> 1, b, 104, 104
120 out = F.conv2d(x,
121 weight,
122 padding=1,
123 groups=B,
124 bias=bias)
125
126 # b, 1, 104, 104
127 out = out.transpose(0,1)
128 return out
129
130
131class CrossAttn(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected