예제 #1
0
def create_dcgan_encoder(args, device):
    net = dcgan.Encoder(args.image_size, args.nc, args.ndf, args.nz, args.n_extra_layers)
    net.apply(model_helper.weights_init)
    print(net)
    optimizer = model_helper.get_optimizer(args, net.parameters())

    if torch.cuda.is_available():
        net = net.type(torch.cuda.FloatTensor)
    return net, optimizer
예제 #2
0
def create_mlp_encoder(args, device):
    net = mlp.Encoder(args.image_size, args.nc, args.enc_layers, args.nz, 
                     activation=nn.LeakyReLU(0.2), use_bn=True, dropout=0)
    net.apply(model_helper.weights_init)
    print(net)
    optimizer = model_helper.get_optimizer(args, net.parameters())

    if torch.cuda.is_available():
        net = net.type(torch.cuda.FloatTensor)
    return net, optimizer