MCPcopy Create free account
hub / github.com/LetheSec/PLG-MI-Attack / InversionNet

Class InversionNet

baselines/generator.py:241–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240
241class InversionNet(nn.Module):
242 def __init__(self, out_dim=128):
243 super(InversionNet, self).__init__()
244
245 # input [4, h, w] output [256, h // 4, w // 4]
246 self.ContextNetwork = ContextNetwork()
247 # input [z_dim] output[128, 16, 16]
248 self.IdentityGenerator = IdentityGenerator()
249
250 self.dim = 128 + 128
251 self.out_dim = out_dim
252
253 self.Dconv = nn.Sequential(
254 dconv_bn_relu(self.dim, self.out_dim),
255 dconv_bn_relu(self.out_dim, self.out_dim // 2))
256
257 self.Conv = nn.Sequential(
258 nn.Conv2d(self.out_dim // 2, self.out_dim // 4, kernel_size=3, stride=1, padding=1),
259 nn.BatchNorm2d(self.out_dim // 4),
260 nn.ReLU(),
261 nn.Conv2d(self.out_dim // 4, 3, kernel_size=3, stride=1, padding=1),
262 nn.Sigmoid())
263
264 def forward(self, inp):
265 # x.shape [4, h, w] z.shape [100]
266 x, z = inp
267 context_info = self.ContextNetwork(x)
268 identity_info = self.IdentityGenerator(z)
269 y = torch.cat((context_info, identity_info), dim=1)
270 y = self.Dconv(y)
271 y = self.Conv(y)
272
273 return y

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected