MCPcopy Create free account
hub / github.com/bingchenlll/FastGAN-pytorch / SimpleDecoder

Class SimpleDecoder

models.py:316–343  ·  view source on GitHub ↗

docstring for CAN_SimpleDecoder

Source from the content-addressed store, hash-verified

314
315
316class SimpleDecoder(nn.Module):
317 """docstring for CAN_SimpleDecoder"""
318 def __init__(self, nfc_in=64, nc=3):
319 super(SimpleDecoder, self).__init__()
320
321 nfc_multi = {4:16, 8:8, 16:4, 32:2, 64:2, 128:1, 256:0.5, 512:0.25, 1024:0.125}
322 nfc = {}
323 for k, v in nfc_multi.items():
324 nfc[k] = int(v*32)
325
326 def upBlock(in_planes, out_planes):
327 block = nn.Sequential(
328 nn.Upsample(scale_factor=2, mode='nearest'),
329 conv2d(in_planes, out_planes*2, 3, 1, 1, bias=False),
330 batchNorm2d(out_planes*2), GLU())
331 return block
332
333 self.main = nn.Sequential( nn.AdaptiveAvgPool2d(8),
334 upBlock(nfc_in, nfc[16]) ,
335 upBlock(nfc[16], nfc[32]),
336 upBlock(nfc[32], nfc[64]),
337 upBlock(nfc[64], nfc[128]),
338 conv2d(nfc[128], nc, 3, 1, 1, bias=False),
339 nn.Tanh() )
340
341 def forward(self, input):
342 # input shape: c x 4 x 4
343 return self.main(input)
344
345from random import randint
346def random_crop(image, size):

Callers 2

__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected