def set_network(depth, ctx, lr, beta1, ndf, ngf,latent, append=True, solver='adam'): # Pixel2pixel networks if append: netD = models.Discriminator(in_channels=6, n_layers =2 , ndf=ndf)##netG = models.CEGenerator(in_channels=3, n_layers=depth, ndf=ngf) # UnetGenerator(in_channels=3, num_downs=8) # netD2 = models.LatentDiscriminator(in_channels=6, n_layers =2 , ndf=ndf)##netG = models.CEGenerator(in_channels=3, n_layers=depth, ndf=ngf) # UnetGenerator(in_channels=3, num_downs=8) # else: netD = models.Discriminator(in_channels=3, n_layers =2 , ndf=ndf) netD2 = models.LatentDiscriminator(in_channels=3, n_layers =2 , ndf=ndf) #netG = models.UnetGenerator(in_channels=3, num_downs =depth, ngf=ngf) # UnetGenerator(in_channels=3, num_downs=8) # #netD = models.Discriminator(in_channels=6, n_layers =depth-1, ndf=ngf/4) netEn = models.Encoder(in_channels=3, n_layers =depth,latent=latent, ndf=ngf) netDe = models.Decoder(in_channels=3, n_layers =depth, latent=latent, ndf=ngf) # Initialize parameters models.network_init(netEn, ctx=ctx) models.network_init(netDe, ctx=ctx) models.network_init(netD, ctx=ctx) models.network_init(netD2, ctx=ctx) trainerEn = gluon.Trainer(netEn.collect_params(), 'adam', {'learning_rate': lr, 'beta1': beta1}) trainerDe = gluon.Trainer(netDe.collect_params(), 'adam', {'learning_rate': lr, 'beta1': beta1}) trainerD = gluon.Trainer(netD.collect_params(), 'adam', {'learning_rate': lr, 'beta1': beta1}) trainerD2 = gluon.Trainer(netD2.collect_params(), 'adam', {'learning_rate': lr, 'beta1': beta1}) return netEn, netDe, netD, netD2, trainerEn, trainerDe, trainerD, trainerD2
def set_network(depth, ctx, lr, beta1, ndf, ngf, append=True): if append: netD = models.Discriminator(in_channels=6, n_layers=depth - 1, istest=True, ndf=ndf) else: netD = models.Discriminator(in_channels=3, n_layers=depth - 1, istest=True, ndf=ndf) netEn = models.Encoder( in_channels=3, n_layers=depth, istest=True, latent=512, ndf=ngf) # UnetGenerator(in_channels=3, num_downs=8) # netDe = models.Decoder( in_channels=3, n_layers=depth, istest=True, latent=512, ndf=ngf) # UnetGenerator(in_channels=3, num_downs=8) # netD2 = models.LatentDiscriminator(in_channels=6, n_layers=2, ndf=ndf) netDS = models.Discriminator(in_channels=3, n_layers=2, ndf=64) return netEn, netDe, netD, netD2, netDS