pytorch实现pix2pix模型的搭建

1.数据获取

facades数据集:base–378, extend–228.
在这里插入图片描述

在这里插入图片描述

2.数据整理

在这里我想把base与extend都作为训练集,所以得需要将它们重新排号。

import os

num = 379
path = 'C:/Users/84218/Desktop/extended'

file = os.listdir(path)
# print(len(file))
# print(file[0])
for i in range(0, len(file), 3):
    portion = os.path.splitext(file[i])
    newname = 'cmp_x' + str('%04d' % num) + portion[1]
    os.rename(os.path.join(path, file[i]), os.path.join(path, newname))
    portion = os.path.splitext(file[i+1])
    newname = 'cmp_x' + str('%04d' % num) + portion[1]
    os.rename(os.path.join(path, file[i+1]), os.path.join(path, newname))
    portion = os.path.splitext(file[i+2])
    newname = 'cmp_x' + str('%04d' % num) + portion[1]
    os.rename(os.path.join(path, file[i+2]), os.path.join(path, newname))
    num = num + 1
print("successful")

在这里插入图片描述
然后放入同一个文件夹即可

3.utils

from torch.utils.data import Dataset
from PIL import Image
import os


def is_image_file(filename):
    return any(filename.endswith(extension) for extension in ['.png', '.jpg', '.jpeg', '.JPG', '.JPEG', '.PNG'])


class DatasetFromFolder(Dataset):
    def __init__(self, img_path, transform=None):
        super(DatasetFromFolder, self).__init__()
        self.input_filenames = []
        self.target_filenames = []
        for file in os.listdir(img_path):
            portion = os.path.splitext(file)
            if portion[1] == '.png':
                self.input_filenames.append(os.path.join(img_path, file))
            elif portion[1] == '.jpg':
                self.target_filenames.append(os.path.join(img_path, file))

        self.transform = transform

    def __getitem__(self, index):
        self.input = self.transform(Image.open(self.input_filenames[index]).convert('RGB'))
        self.target = self.transform(Image.open(self.target_filenames[index]).convert('RGB'))
        return self.input, self.target

    def __len__(self):
        return len(self.input_filenames)

.png格式的图片为输入,.jpg格式的图片为输出,保证都为三通道。

4.model

import torch
import torch.nn as nn


class down_sample(nn.Module):
    def __init__(self, in_channels, out_channels):
        super(down_sample, self).__init__()

        self.do = nn.Sequential(
            nn.Conv2d(in_channels, out_channels, kernel_size=4, stride=2, padding=1),
            nn.BatchNorm2d(out_channels),
            nn.LeakyReLU(0.2, True)
        )

    def forward(self, x):
        return self.do(x)


class up_sample(nn.Module):
    def __init__(self, in_channels, out_channels):
        super(up_sample, self).__init__()

        self.do = nn.Sequential(
            nn.ConvTranspose2d(in_channels, out_channels, kernel_size=4, stride=2, padding=1),
            nn.BatchNorm2d(out_channels),
            nn.ReLU(True),
            nn.Dropout(p=0.5)
        )

    def forward(self, x):
        return self.do(x)


class UnetGen(nn.Module):
    def __init__(self):
        super(UnetGen, self).__init__()

        self.down1 = down_sample(3, 64)
        self.down2 = down_sample(64, 128)
        self.down3 = down_sample(128, 256)
        self.down4 = down_sample(256, 512)
        self.down5 = down_sample(512, 512)
        self.down6 = down_sample(512, 512)
        self.down7 = down_sample(512, 512)
        self.down8 = down_sample(512, 512)
        self.up1 = up_sample(512, 512)
        self.up2 = up_sample(1024, 512)
        self.up3 = up_sample(1024, 512)
        self.up4 = up_sample(1024, 512)
        self.up5 = up_sample(1024, 256)
        self.up6 = up_sample(512, 128)
        self.up7 = up_sample(256, 64)
        self.up8 = nn.Sequential(
            nn.ConvTranspose2d(128, 3, kernel_size=4, stride=2, padding=1),
            nn.Tanh()
        )

    def forward(self, x):
        x1 = self.down1(x)
        x2 = self.down2(x1)
        x3 = self.down3(x2)
        x4 = self.down4(x3)
        x5 = self.down5(x4)
        x6 = self.down6(x5)
        x7 = self.down7(x6)
        x = self.down8(x7)
        x8 = torch.cat((x7, self.up1(x)), dim=1)
        x9 = torch.cat((x6, self.up2(x8)), dim=1)
        x10 = torch.cat((x5, self.up3(x9)), dim=1)
        x11 = torch.cat((x4, self.up4(x10)), dim=1)
        x12 = torch.cat((x3, self.up5(x11)), dim=1)
        x13 = torch.cat((x2, self.up6(x12)), dim=1)
        x14 = torch.cat((x1, self.up7(x13)), dim=1)

        return self.up8(x14)


class PatchDisr(nn.Module):
    def __init__(self):
        super(PatchDisr, self).__init__()

        self.conv1 = nn.Conv2d(6, 64, kernel_size=4, stride=2, padding=1)
        self.conv2 = nn.Conv2d(64, 128, kernel_size=4, stride=2, padding=1)
        self.conv3 = nn.Conv2d(128, 256, kernel_size=4, stride=2, padding=1)
        self.conv4 = nn.Conv2d(256, 512, kernel_size=4, stride=1, padding=1)
        self.conv5 = nn.Conv2d(512, 1, kernel_size=4, stride=1, padding=1)
        self.bn1 = nn.BatchNorm2d(64)
        self.bn2 = nn.BatchNorm2d(128)
        self.bn3 = nn.BatchNorm2d(256)
        self.bn4 = nn.BatchNorm2d(512)
        self.lrelu = nn.LeakyReLU(0.2)
        self.sigmoid = nn.Sigmoid()

    def forward(self, x, y):
        x = torch.cat((x, y), dim=1)
        x = self.lrelu(self.bn1(self.conv1(x)))
        x = self.lrelu(self.bn2(self.conv2(x)))
        x = self.lrelu(self.bn3(self.conv3(x)))
        x = self.lrelu(self.bn4(self.conv4(x)))

        return self.sigmoid(self.conv5(x))

5.train

import torch
import torch.nn as nn
import time
from model import UnetGen, PatchDisr
import torchvision.transforms as transforms
from utils import DatasetFromFolder
from torch.utils.data import DataLoader

D_lr = 1e-5
G_lr = 2e-4
num_epochs = 100
img_path = 'data'
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

data_transform = transforms.Compose([
    transforms.RandomResizedCrop(256),
    transforms.ToTensor(),
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])

train_dataset = DatasetFromFolder(img_path, transform=data_transform)
train_loader = DataLoader(train_dataset, batch_size=30, shuffle=True)
start_time = time.time()
D_losses = []
G_losses = []
G_model = UnetGen().to(device)
D_model = PatchDisr().to(device)

optim_gen = torch.optim.Adam(G_model.parameters(), betas=(0.5, 0.999), lr=G_lr)
optim_disc = torch.optim.Adam(D_model.parameters(), betas=(0.5, 0.999), lr=D_lr)

criterion = nn.BCELoss(reduction="mean")
L1 = nn.L1Loss()
for epoch in range(num_epochs):
    G_model = G_model.train()
    D_model = D_model.train()

    for batch_idx, (x, y) in enumerate(train_loader):
        x = x.to(device)
        y = y.to(device)
        gx = G_model(x)
        dgx1 = D_model(gx, x).mean()
        G_loss = criterion(dgx1, torch.ones_like(dgx1)) + L1(gx, y) * 3

        optim_gen.zero_grad()
        G_loss.backward()
        optim_gen.step()

        dxy = D_model(y, x).mean()
        real_loss = criterion(dxy, torch.ones_like(dxy))
        dgx2 = D_model(gx.detach(), x).mean()
        fake_loss = criterion(dgx2, torch.zeros_like(dgx2))
        D_loss = (fake_loss + real_loss) * 0.5

        optim_disc.zero_grad()
        D_loss.backward()
        optim_disc.step()

        G_losses.append(G_loss)
        D_losses.append(D_loss)

        if not batch_idx % 10:
            print('Epoch: %03d/%03d | Batch %03d/%03d | Gen/Dis Loss: %.4f/%.4f'
                  % (epoch + 1, num_epochs, batch_idx,
                     len(train_loader), G_loss, D_loss))

    print('Time elapsed: %.2f min' % ((time.time() - start_time) / 60))

print('Total Training Time: %.2f min' % ((time.time() - start_time) / 60))

torch.save(G_model.state_dict(), 'pix2pix.pt')

这里学习率稍作了调整,lambda是随便设置的

D:\ProgramData\Anaconda3\envs\pytorch\python.exe D:/PycharmProjects/network/GAN/pix2pix/train.py
Epoch: 001/100 | Batch 000/021 | Gen/Dis Loss: 2.8234/0.6933
Epoch: 001/100 | Batch 010/021 | Gen/Dis Loss: 2.1937/0.6770
Epoch: 001/100 | Batch 020/021 | Gen/Dis Loss: 2.1756/0.6648
Time elapsed: 0.32 min
Epoch: 002/100 | Batch 000/021 | Gen/Dis Loss: 2.2190/0.6583
Epoch: 002/100 | Batch 010/021 | Gen/Dis Loss: 2.0980/0.6732
Epoch: 002/100 | Batch 020/021 | Gen/Dis Loss: 2.1937/0.6628
Time elapsed: 0.60 min
Epoch: 003/100 | Batch 000/021 | Gen/Dis Loss: 2.1502/0.6471
Epoch: 003/100 | Batch 010/021 | Gen/Dis Loss: 2.0211/0.6349
Epoch: 003/100 | Batch 020/021 | Gen/Dis Loss: 2.0344/0.6637
Time elapsed: 0.88 min
Epoch: 004/100 | Batch 000/021 | Gen/Dis Loss: 2.0440/0.6553
Epoch: 004/100 | Batch 010/021 | Gen/Dis Loss: 2.0292/0.6379
Epoch: 004/100 | Batch 020/021 | Gen/Dis Loss: 2.0869/0.6501
Time elapsed: 1.16 min
Epoch: 005/100 | Batch 000/021 | Gen/Dis Loss: 2.0215/0.6417
Epoch: 005/100 | Batch 010/021 | Gen/Dis Loss: 1.9782/0.6197
Epoch: 005/100 | Batch 020/021 | Gen/Dis Loss: 2.2299/0.6394
Time elapsed: 1.45 min
Epoch: 006/100 | Batch 000/021 | Gen/Dis Loss: 2.1585/0.6441
Epoch: 006/100 | Batch 010/021 | Gen/Dis Loss: 2.0305/0.6663
Epoch: 006/100 | Batch 020/021 | Gen/Dis Loss: 2.0731/0.6436
Time elapsed: 1.71 min
Epoch: 007/100 | Batch 000/021 | Gen/Dis Loss: 2.0280/0.6441
Epoch: 007/100 | Batch 010/021 | Gen/Dis Loss: 2.1072/0.6293
Epoch: 007/100 | Batch 020/021 | Gen/Dis Loss: 1.9214/0.6552
Time elapsed: 1.98 min
Epoch: 008/100 | Batch 000/021 | Gen/Dis Loss: 1.8599/0.6725
Epoch: 008/100 | Batch 010/021 | Gen/Dis Loss: 2.1657/0.6759
Epoch: 008/100 | Batch 020/021 | Gen/Dis Loss: 1.8384/0.6186
Time elapsed: 2.26 min
Epoch: 009/100 | Batch 000/021 | Gen/Dis Loss: 1.9135/0.5789
Epoch: 009/100 | Batch 010/021 | Gen/Dis Loss: 1.9593/0.6784
Epoch: 009/100 | Batch 020/021 | Gen/Dis Loss: 1.8526/0.7045
Time elapsed: 2.53 min
Epoch: 010/100 | Batch 000/021 | Gen/Dis Loss: 2.1261/0.6520
Epoch: 010/100 | Batch 010/021 | Gen/Dis Loss: 2.0124/0.6660
Epoch: 010/100 | Batch 020/021 | Gen/Dis Loss: 2.1358/0.7611
Time elapsed: 2.78 min
Epoch: 011/100 | Batch 000/021 | Gen/Dis Loss: 2.2197/0.6681
Epoch: 011/100 | Batch 010/021 | Gen/Dis Loss: 2.1090/0.6415
Epoch: 011/100 | Batch 020/021 | Gen/Dis Loss: 2.0682/0.6537
Time elapsed: 3.05 min
Epoch: 012/100 | Batch 000/021 | Gen/Dis Loss: 2.1099/0.6631
Epoch: 012/100 | Batch 010/021 | Gen/Dis Loss: 2.0178/0.6544
Epoch: 012/100 | Batch 020/021 | Gen/Dis Loss: 2.0546/0.6944
Time elapsed: 3.30 min
Epoch: 013/100 | Batch 000/021 | Gen/Dis Loss: 1.9440/0.6457
Epoch: 013/100 | Batch 010/021 | Gen/Dis Loss: 1.9910/0.6402
Epoch: 013/100 | Batch 020/021 | Gen/Dis Loss: 2.2445/0.6889
Time elapsed: 3.56 min
Epoch: 014/100 | Batch 000/021 | Gen/Dis Loss: 2.0290/0.6549
Epoch: 014/100 | Batch 010/021 | Gen/Dis Loss: 1.9795/0.7229
Epoch: 014/100 | Batch 020/021 | Gen/Dis Loss: 2.1195/0.7145
Time elapsed: 3.82 min
Epoch: 015/100 | Batch 000/021 | Gen/Dis Loss: 2.0101/0.6600
Epoch: 015/100 | Batch 010/021 | Gen/Dis Loss: 1.9934/0.7484
Epoch: 015/100 | Batch 020/021 | Gen/Dis Loss: 2.1339/0.6275
Time elapsed: 4.08 min
Epoch: 016/100 | Batch 000/021 | Gen/Dis Loss: 2.0147/0.6289
Epoch: 016/100 | Batch 010/021 | Gen/Dis Loss: 2.1254/0.6941
Epoch: 016/100 | Batch 020/021 | Gen/Dis Loss: 2.1598/0.6604
Time elapsed: 4.35 min
Epoch: 017/100 | Batch 000/021 | Gen/Dis Loss: 2.0910/0.6619
Epoch: 017/100 | Batch 010/021 | Gen/Dis Loss: 1.9139/0.6788
Epoch: 017/100 | Batch 020/021 | Gen/Dis Loss: 2.1197/0.6803
Time elapsed: 4.62 min
Epoch: 018/100 | Batch 000/021 | Gen/Dis Loss: 1.9659/0.6687
Epoch: 018/100 | Batch 010/021 | Gen/Dis Loss: 1.9975/0.6925
Epoch: 018/100 | Batch 020/021 | Gen/Dis Loss: 1.9430/0.6507
Time elapsed: 4.88 min
Epoch: 019/100 | Batch 000/021 | Gen/Dis Loss: 1.9349/0.6125
Epoch: 019/100 | Batch 010/021 | Gen/Dis Loss: 1.8987/0.7076
Epoch: 019/100 | Batch 020/021 | Gen/Dis Loss: 2.1035/0.7013
Time elapsed: 5.14 min
Epoch: 020/100 | Batch 000/021 | Gen/Dis Loss: 2.0696/0.6833
Epoch: 020/100 | Batch 010/021 | Gen/Dis Loss: 1.9822/0.6563
Epoch: 020/100 | Batch 020/021 | Gen/Dis Loss: 1.9745/0.7099
Time elapsed: 5.40 min
Epoch: 021/100 | Batch 000/021 | Gen/Dis Loss: 1.9619/0.7005
Epoch: 021/100 | Batch 010/021 | Gen/Dis Loss: 2.0937/0.6642
Epoch: 021/100 | Batch 020/021 | Gen/Dis Loss: 2.0975/0.6543
Time elapsed: 5.66 min
Epoch: 022/100 | Batch 000/021 | Gen/Dis Loss: 1.9703/0.6822
Epoch: 022/100 | Batch 010/021 | Gen/Dis Loss: 2.1025/0.6980
Epoch: 022/100 | Batch 020/021 | Gen/Dis Loss: 2.0652/0.7094
Time elapsed: 5.92 min
Epoch: 023/100 | Batch 000/021 | Gen/Dis Loss: 1.9101/0.6762
Epoch: 023/100 | Batch 010/021 | Gen/Dis Loss: 1.9844/0.6613
Epoch: 023/100 | Batch 020/021 | Gen/Dis Loss: 2.0575/0.6989
Time elapsed: 6.18 min
Epoch: 024/100 | Batch 000/021 | Gen/Dis Loss: 2.0534/0.7021
Epoch: 024/100 | Batch 010/021 | Gen/Dis Loss: 2.0319/0.6713
Epoch: 024/100 | Batch 020/021 | Gen/Dis Loss: 2.1020/0.6559
Time elapsed: 6.45 min
Epoch: 025/100 | Batch 000/021 | Gen/Dis Loss: 2.1594/0.6431
Epoch: 025/100 | Batch 010/021 | Gen/Dis Loss: 1.9785/0.7101
Epoch: 025/100 | Batch 020/021 | Gen/Dis Loss: 2.0112/0.7139
Time elapsed: 6.71 min
Epoch: 026/100 | Batch 000/021 | Gen/Dis Loss: 2.0112/0.6704
Epoch: 026/100 | Batch 010/021 | Gen/Dis Loss: 1.9380/0.6576
Epoch: 026/100 | Batch 020/021 | Gen/Dis Loss: 2.1703/0.6503
Time elapsed: 6.97 min
Epoch: 027/100 | Batch 000/021 | Gen/Dis Loss: 1.9967/0.6899
Epoch: 027/100 | Batch 010/021 | Gen/Dis Loss: 1.9994/0.6795
Epoch: 027/100 | Batch 020/021 | Gen/Dis Loss: 2.0112/0.6735
Time elapsed: 7.24 min
Epoch: 028/100 | Batch 000/021 | Gen/Dis Loss: 2.0045/0.6761
Epoch: 028/100 | Batch 010/021 | Gen/Dis Loss: 1.9527/0.7002
Epoch: 028/100 | Batch 020/021 | Gen/Dis Loss: 2.0108/0.7105
Time elapsed: 7.50 min
Epoch: 029/100 | Batch 000/021 | Gen/Dis Loss: 2.0257/0.6588
Epoch: 029/100 | Batch 010/021 | Gen/Dis Loss: 2.0725/0.6668
Epoch: 029/100 | Batch 020/021 | Gen/Dis Loss: 1.9816/0.6823
Time elapsed: 7.77 min
Epoch: 030/100 | Batch 000/021 | Gen/Dis Loss: 1.9930/0.6619
Epoch: 030/100 | Batch 010/021 | Gen/Dis Loss: 2.0173/0.7187
Epoch: 030/100 | Batch 020/021 | Gen/Dis Loss: 2.1800/0.7348
Time elapsed: 8.03 min
Epoch: 031/100 | Batch 000/021 | Gen/Dis Loss: 2.1731/0.6362
Epoch: 031/100 | Batch 010/021 | Gen/Dis Loss: 1.9611/0.6775
Epoch: 031/100 | Batch 020/021 | Gen/Dis Loss: 2.2262/0.6450
Time elapsed: 8.29 min
Epoch: 032/100 | Batch 000/021 | Gen/Dis Loss: 1.8990/0.6414
Epoch: 032/100 | Batch 010/021 | Gen/Dis Loss: 1.9603/0.7257
Epoch: 032/100 | Batch 020/021 | Gen/Dis Loss: 2.0627/0.7464
Time elapsed: 8.56 min
Epoch: 033/100 | Batch 000/021 | Gen/Dis Loss: 2.0700/0.7005
Epoch: 033/100 | Batch 010/021 | Gen/Dis Loss: 2.0509/0.6906
Epoch: 033/100 | Batch 020/021 | Gen/Dis Loss: 1.8135/0.7211
Time elapsed: 8.82 min
Epoch: 034/100 | Batch 000/021 | Gen/Dis Loss: 1.9302/0.6277
Epoch: 034/100 | Batch 010/021 | Gen/Dis Loss: 1.8751/0.6933
Epoch: 034/100 | Batch 020/021 | Gen/Dis Loss: 2.0729/0.6627
Time elapsed: 9.09 min
Epoch: 035/100 | Batch 000/021 | Gen/Dis Loss: 2.1066/0.6631
Epoch: 035/100 | Batch 010/021 | Gen/Dis Loss: 2.0413/0.7029
Epoch: 035/100 | Batch 020/021 | Gen/Dis Loss: 1.8909/0.6785
Time elapsed: 9.36 min
Epoch: 036/100 | Batch 000/021 | Gen/Dis Loss: 1.9903/0.6142
Epoch: 036/100 | Batch 010/021 | Gen/Dis Loss: 2.0835/0.6355
Epoch: 036/100 | Batch 020/021 | Gen/Dis Loss: 1.8243/0.6578
Time elapsed: 9.62 min
Epoch: 037/100 | Batch 000/021 | Gen/Dis Loss: 2.0933/0.6813
Epoch: 037/100 | Batch 010/021 | Gen/Dis Loss: 2.0120/0.6918
Epoch: 037/100 | Batch 020/021 | Gen/Dis Loss: 2.2465/0.6986
Time elapsed: 9.89 min
Epoch: 038/100 | Batch 000/021 | Gen/Dis Loss: 2.0045/0.6555
Epoch: 038/100 | Batch 010/021 | Gen/Dis Loss: 2.0190/0.6887
Epoch: 038/100 | Batch 020/021 | Gen/Dis Loss: 2.0670/0.6914
Time elapsed: 10.16 min
Epoch: 039/100 | Batch 000/021 | Gen/Dis Loss: 1.9691/0.6908
Epoch: 039/100 | Batch 010/021 | Gen/Dis Loss: 2.0349/0.6890
Epoch: 039/100 | Batch 020/021 | Gen/Dis Loss: 2.0761/0.6748
Time elapsed: 10.42 min
Epoch: 040/100 | Batch 000/021 | Gen/Dis Loss: 1.9686/0.7106
Epoch: 040/100 | Batch 010/021 | Gen/Dis Loss: 2.0011/0.6599
Epoch: 040/100 | Batch 020/021 | Gen/Dis Loss: 1.9946/0.7063
Time elapsed: 10.69 min
Epoch: 041/100 | Batch 000/021 | Gen/Dis Loss: 2.0063/0.6903
Epoch: 041/100 | Batch 010/021 | Gen/Dis Loss: 1.9842/0.6749
Epoch: 041/100 | Batch 020/021 | Gen/Dis Loss: 2.1267/0.6823
Time elapsed: 10.96 min
Epoch: 042/100 | Batch 000/021 | Gen/Dis Loss: 2.1047/0.7137
Epoch: 042/100 | Batch 010/021 | Gen/Dis Loss: 2.0900/0.7356
Epoch: 042/100 | Batch 020/021 | Gen/Dis Loss: 1.8917/0.6688
Time elapsed: 11.23 min
Epoch: 043/100 | Batch 000/021 | Gen/Dis Loss: 2.0092/0.6800
Epoch: 043/100 | Batch 010/021 | Gen/Dis Loss: 2.0197/0.6444
Epoch: 043/100 | Batch 020/021 | Gen/Dis Loss: 2.0334/0.7349
Time elapsed: 11.51 min
Epoch: 044/100 | Batch 000/021 | Gen/Dis Loss: 2.0973/0.6924
Epoch: 044/100 | Batch 010/021 | Gen/Dis Loss: 1.9293/0.6533
Epoch: 044/100 | Batch 020/021 | Gen/Dis Loss: 2.0556/0.6811
Time elapsed: 11.78 min
Epoch: 045/100 | Batch 000/021 | Gen/Dis Loss: 2.0853/0.6996
Epoch: 045/100 | Batch 010/021 | Gen/Dis Loss: 2.0674/0.7069
Epoch: 045/100 | Batch 020/021 | Gen/Dis Loss: 2.0165/0.6960
Time elapsed: 12.05 min
Epoch: 046/100 | Batch 000/021 | Gen/Dis Loss: 1.9859/0.6760
Epoch: 046/100 | Batch 010/021 | Gen/Dis Loss: 2.0014/0.6916
Epoch: 046/100 | Batch 020/021 | Gen/Dis Loss: 2.0876/0.6862
Time elapsed: 12.31 min
Epoch: 047/100 | Batch 000/021 | Gen/Dis Loss: 2.0621/0.7119
Epoch: 047/100 | Batch 010/021 | Gen/Dis Loss: 1.9317/0.6692
Epoch: 047/100 | Batch 020/021 | Gen/Dis Loss: 1.9147/0.7022
Time elapsed: 12.58 min
Epoch: 048/100 | Batch 000/021 | Gen/Dis Loss: 2.0916/0.6499
Epoch: 048/100 | Batch 010/021 | Gen/Dis Loss: 2.0933/0.7182
Epoch: 048/100 | Batch 020/021 | Gen/Dis Loss: 2.0813/0.6439
Time elapsed: 12.85 min
Epoch: 049/100 | Batch 000/021 | Gen/Dis Loss: 2.0550/0.6702
Epoch: 049/100 | Batch 010/021 | Gen/Dis Loss: 2.0569/0.7132
Epoch: 049/100 | Batch 020/021 | Gen/Dis Loss: 1.9934/0.6938
Time elapsed: 13.12 min
Epoch: 050/100 | Batch 000/021 | Gen/Dis Loss: 2.0385/0.6708
Epoch: 050/100 | Batch 010/021 | Gen/Dis Loss: 2.1244/0.6582
Epoch: 050/100 | Batch 020/021 | Gen/Dis Loss: 1.9644/0.6227
Time elapsed: 13.39 min
Epoch: 051/100 | Batch 000/021 | Gen/Dis Loss: 1.9470/0.6208
Epoch: 051/100 | Batch 010/021 | Gen/Dis Loss: 1.9786/0.6833
Epoch: 051/100 | Batch 020/021 | Gen/Dis Loss: 2.0253/0.6597
Time elapsed: 13.66 min
Epoch: 052/100 | Batch 000/021 | Gen/Dis Loss: 2.0423/0.6828
Epoch: 052/100 | Batch 010/021 | Gen/Dis Loss: 2.1221/0.6801
Epoch: 052/100 | Batch 020/021 | Gen/Dis Loss: 1.8676/0.7507
Time elapsed: 13.92 min
Epoch: 053/100 | Batch 000/021 | Gen/Dis Loss: 1.9496/0.6760
Epoch: 053/100 | Batch 010/021 | Gen/Dis Loss: 1.9536/0.6666
Epoch: 053/100 | Batch 020/021 | Gen/Dis Loss: 2.1215/0.7216
Time elapsed: 14.19 min
Epoch: 054/100 | Batch 000/021 | Gen/Dis Loss: 2.0579/0.6649
Epoch: 054/100 | Batch 010/021 | Gen/Dis Loss: 1.9739/0.7048
Epoch: 054/100 | Batch 020/021 | Gen/Dis Loss: 2.0225/0.7609
Time elapsed: 14.46 min
Epoch: 055/100 | Batch 000/021 | Gen/Dis Loss: 2.0385/0.6950
Epoch: 055/100 | Batch 010/021 | Gen/Dis Loss: 2.0689/0.6831
Epoch: 055/100 | Batch 020/021 | Gen/Dis Loss: 2.0844/0.6679
Time elapsed: 14.73 min
Epoch: 056/100 | Batch 000/021 | Gen/Dis Loss: 1.9451/0.6530
Epoch: 056/100 | Batch 010/021 | Gen/Dis Loss: 2.0021/0.6948
Epoch: 056/100 | Batch 020/021 | Gen/Dis Loss: 2.2002/0.6598
Time elapsed: 15.00 min
Epoch: 057/100 | Batch 000/021 | Gen/Dis Loss: 2.0978/0.6776
Epoch: 057/100 | Batch 010/021 | Gen/Dis Loss: 1.8536/0.6301
Epoch: 057/100 | Batch 020/021 | Gen/Dis Loss: 2.2501/0.7123
Time elapsed: 15.27 min
Epoch: 058/100 | Batch 000/021 | Gen/Dis Loss: 2.1183/0.7400
Epoch: 058/100 | Batch 010/021 | Gen/Dis Loss: 2.0599/0.6333
Epoch: 058/100 | Batch 020/021 | Gen/Dis Loss: 2.1436/0.6401
Time elapsed: 15.54 min
Epoch: 059/100 | Batch 000/021 | Gen/Dis Loss: 2.0116/0.6337
Epoch: 059/100 | Batch 010/021 | Gen/Dis Loss: 2.0214/0.7035
Epoch: 059/100 | Batch 020/021 | Gen/Dis Loss: 1.9712/0.6656
Time elapsed: 15.81 min
Epoch: 060/100 | Batch 000/021 | Gen/Dis Loss: 1.9676/0.6605
Epoch: 060/100 | Batch 010/021 | Gen/Dis Loss: 2.0077/0.6727
Epoch: 060/100 | Batch 020/021 | Gen/Dis Loss: 2.0964/0.6700
Time elapsed: 16.07 min
Epoch: 061/100 | Batch 000/021 | Gen/Dis Loss: 1.9620/0.7007
Epoch: 061/100 | Batch 010/021 | Gen/Dis Loss: 1.9883/0.7111
Epoch: 061/100 | Batch 020/021 | Gen/Dis Loss: 2.0194/0.7276
Time elapsed: 16.34 min
Epoch: 062/100 | Batch 000/021 | Gen/Dis Loss: 1.9908/0.6755
Epoch: 062/100 | Batch 010/021 | Gen/Dis Loss: 1.9512/0.7019
Epoch: 062/100 | Batch 020/021 | Gen/Dis Loss: 1.8624/0.7265
Time elapsed: 16.61 min
Epoch: 063/100 | Batch 000/021 | Gen/Dis Loss: 2.0148/0.6922
Epoch: 063/100 | Batch 010/021 | Gen/Dis Loss: 1.9706/0.7113
Epoch: 063/100 | Batch 020/021 | Gen/Dis Loss: 1.9190/0.7050
Time elapsed: 16.89 min
Epoch: 064/100 | Batch 000/021 | Gen/Dis Loss: 1.9262/0.6925
Epoch: 064/100 | Batch 010/021 | Gen/Dis Loss: 1.9798/0.6817
Epoch: 064/100 | Batch 020/021 | Gen/Dis Loss: 2.1237/0.7089
Time elapsed: 17.16 min
Epoch: 065/100 | Batch 000/021 | Gen/Dis Loss: 2.0750/0.6618
Epoch: 065/100 | Batch 010/021 | Gen/Dis Loss: 2.0909/0.6915
Epoch: 065/100 | Batch 020/021 | Gen/Dis Loss: 1.9240/0.6914
Time elapsed: 17.44 min
Epoch: 066/100 | Batch 000/021 | Gen/Dis Loss: 2.1000/0.6521
Epoch: 066/100 | Batch 010/021 | Gen/Dis Loss: 2.0551/0.6258
Epoch: 066/100 | Batch 020/021 | Gen/Dis Loss: 1.9679/0.7050
Time elapsed: 17.71 min
Epoch: 067/100 | Batch 000/021 | Gen/Dis Loss: 2.0529/0.6369
Epoch: 067/100 | Batch 010/021 | Gen/Dis Loss: 2.0642/0.6914
Epoch: 067/100 | Batch 020/021 | Gen/Dis Loss: 2.0933/0.6583
Time elapsed: 17.98 min
Epoch: 068/100 | Batch 000/021 | Gen/Dis Loss: 2.0226/0.6468
Epoch: 068/100 | Batch 010/021 | Gen/Dis Loss: 2.0102/0.7188
Epoch: 068/100 | Batch 020/021 | Gen/Dis Loss: 2.0289/0.6498
Time elapsed: 18.26 min
Epoch: 069/100 | Batch 000/021 | Gen/Dis Loss: 2.0010/0.7189
Epoch: 069/100 | Batch 010/021 | Gen/Dis Loss: 2.0723/0.7063
Epoch: 069/100 | Batch 020/021 | Gen/Dis Loss: 2.0154/0.6948
Time elapsed: 18.53 min
Epoch: 070/100 | Batch 000/021 | Gen/Dis Loss: 2.0403/0.7143
Epoch: 070/100 | Batch 010/021 | Gen/Dis Loss: 2.0381/0.6861
Epoch: 070/100 | Batch 020/021 | Gen/Dis Loss: 2.0290/0.6798
Time elapsed: 18.80 min
Epoch: 071/100 | Batch 000/021 | Gen/Dis Loss: 2.0539/0.6643
Epoch: 071/100 | Batch 010/021 | Gen/Dis Loss: 1.9484/0.6826
Epoch: 071/100 | Batch 020/021 | Gen/Dis Loss: 2.0940/0.7184
Time elapsed: 19.07 min
Epoch: 072/100 | Batch 000/021 | Gen/Dis Loss: 2.0884/0.6622
Epoch: 072/100 | Batch 010/021 | Gen/Dis Loss: 2.0115/0.7182
Epoch: 072/100 | Batch 020/021 | Gen/Dis Loss: 2.0757/0.6767
Time elapsed: 19.34 min
Epoch: 073/100 | Batch 000/021 | Gen/Dis Loss: 2.0766/0.6483
Epoch: 073/100 | Batch 010/021 | Gen/Dis Loss: 2.0376/0.6826
Epoch: 073/100 | Batch 020/021 | Gen/Dis Loss: 2.1943/0.7751
Time elapsed: 19.61 min
Epoch: 074/100 | Batch 000/021 | Gen/Dis Loss: 2.0069/0.6587
Epoch: 074/100 | Batch 010/021 | Gen/Dis Loss: 2.1234/0.7085
Epoch: 074/100 | Batch 020/021 | Gen/Dis Loss: 1.8359/0.5404
Time elapsed: 19.88 min
Epoch: 075/100 | Batch 000/021 | Gen/Dis Loss: 1.9008/0.5547
Epoch: 075/100 | Batch 010/021 | Gen/Dis Loss: 2.0343/0.6759
Epoch: 075/100 | Batch 020/021 | Gen/Dis Loss: 2.0622/0.8105
Time elapsed: 20.15 min
Epoch: 076/100 | Batch 000/021 | Gen/Dis Loss: 2.1331/0.6969
Epoch: 076/100 | Batch 010/021 | Gen/Dis Loss: 2.0487/0.6925
Epoch: 076/100 | Batch 020/021 | Gen/Dis Loss: 2.0821/0.6864
Time elapsed: 20.42 min
Epoch: 077/100 | Batch 000/021 | Gen/Dis Loss: 2.0247/0.6910
Epoch: 077/100 | Batch 010/021 | Gen/Dis Loss: 1.9415/0.6774
Epoch: 077/100 | Batch 020/021 | Gen/Dis Loss: 2.0936/0.6960
Time elapsed: 20.69 min
Epoch: 078/100 | Batch 000/021 | Gen/Dis Loss: 2.0055/0.6673
Epoch: 078/100 | Batch 010/021 | Gen/Dis Loss: 2.0148/0.6962
Epoch: 078/100 | Batch 020/021 | Gen/Dis Loss: 1.9048/0.7269
Time elapsed: 20.98 min
Epoch: 079/100 | Batch 000/021 | Gen/Dis Loss: 2.0987/0.6507
Epoch: 079/100 | Batch 010/021 | Gen/Dis Loss: 1.9607/0.7024
Epoch: 079/100 | Batch 020/021 | Gen/Dis Loss: 2.1538/0.6742
Time elapsed: 21.27 min
Epoch: 080/100 | Batch 000/021 | Gen/Dis Loss: 2.0001/0.7090
Epoch: 080/100 | Batch 010/021 | Gen/Dis Loss: 2.0831/0.6838
Epoch: 080/100 | Batch 020/021 | Gen/Dis Loss: 2.1759/0.6924
Time elapsed: 21.55 min
Epoch: 081/100 | Batch 000/021 | Gen/Dis Loss: 1.9955/0.6812
Epoch: 081/100 | Batch 010/021 | Gen/Dis Loss: 2.1119/0.6568
Epoch: 081/100 | Batch 020/021 | Gen/Dis Loss: 1.9708/0.7463
Time elapsed: 21.83 min
Epoch: 082/100 | Batch 000/021 | Gen/Dis Loss: 2.0281/0.6682
Epoch: 082/100 | Batch 010/021 | Gen/Dis Loss: 1.9876/0.6796
Epoch: 082/100 | Batch 020/021 | Gen/Dis Loss: 1.9253/0.6722
Time elapsed: 22.11 min
Epoch: 083/100 | Batch 000/021 | Gen/Dis Loss: 2.0497/0.6211
Epoch: 083/100 | Batch 010/021 | Gen/Dis Loss: 2.0022/0.6872
Epoch: 083/100 | Batch 020/021 | Gen/Dis Loss: 2.0167/0.6750
Time elapsed: 22.39 min
Epoch: 084/100 | Batch 000/021 | Gen/Dis Loss: 2.0729/0.6694
Epoch: 084/100 | Batch 010/021 | Gen/Dis Loss: 2.0699/0.6913
Epoch: 084/100 | Batch 020/021 | Gen/Dis Loss: 2.1289/0.6726
Time elapsed: 22.67 min
Epoch: 085/100 | Batch 000/021 | Gen/Dis Loss: 2.0256/0.6832
Epoch: 085/100 | Batch 010/021 | Gen/Dis Loss: 1.9798/0.6995
Epoch: 085/100 | Batch 020/021 | Gen/Dis Loss: 2.1454/0.6772
Time elapsed: 22.96 min
Epoch: 086/100 | Batch 000/021 | Gen/Dis Loss: 2.0687/0.6954
Epoch: 086/100 | Batch 010/021 | Gen/Dis Loss: 1.9412/0.6708
Epoch: 086/100 | Batch 020/021 | Gen/Dis Loss: 2.1527/0.6781
Time elapsed: 23.23 min
Epoch: 087/100 | Batch 000/021 | Gen/Dis Loss: 2.0000/0.7109
Epoch: 087/100 | Batch 010/021 | Gen/Dis Loss: 2.0463/0.6764
Epoch: 087/100 | Batch 020/021 | Gen/Dis Loss: 2.0341/0.6646
Time elapsed: 23.50 min
Epoch: 088/100 | Batch 000/021 | Gen/Dis Loss: 2.0536/0.6416
Epoch: 088/100 | Batch 010/021 | Gen/Dis Loss: 2.0048/0.7138
Epoch: 088/100 | Batch 020/021 | Gen/Dis Loss: 1.9380/0.6988
Time elapsed: 23.76 min
Epoch: 089/100 | Batch 000/021 | Gen/Dis Loss: 2.0210/0.6535
Epoch: 089/100 | Batch 010/021 | Gen/Dis Loss: 2.0526/0.6855
Epoch: 089/100 | Batch 020/021 | Gen/Dis Loss: 1.9934/0.7281
Time elapsed: 24.03 min
Epoch: 090/100 | Batch 000/021 | Gen/Dis Loss: 2.0155/0.6825
Epoch: 090/100 | Batch 010/021 | Gen/Dis Loss: 1.9510/0.6814
Epoch: 090/100 | Batch 020/021 | Gen/Dis Loss: 2.1190/0.7020
Time elapsed: 24.29 min
Epoch: 091/100 | Batch 000/021 | Gen/Dis Loss: 2.0420/0.6900
Epoch: 091/100 | Batch 010/021 | Gen/Dis Loss: 2.0094/0.6895
Epoch: 091/100 | Batch 020/021 | Gen/Dis Loss: 2.1088/0.6907
Time elapsed: 24.56 min
Epoch: 092/100 | Batch 000/021 | Gen/Dis Loss: 1.9664/0.6621
Epoch: 092/100 | Batch 010/021 | Gen/Dis Loss: 2.0986/0.6764
Epoch: 092/100 | Batch 020/021 | Gen/Dis Loss: 1.9894/0.7339
Time elapsed: 24.82 min
Epoch: 093/100 | Batch 000/021 | Gen/Dis Loss: 2.1166/0.6484
Epoch: 093/100 | Batch 010/021 | Gen/Dis Loss: 2.0234/0.6742
Epoch: 093/100 | Batch 020/021 | Gen/Dis Loss: 2.1447/0.7302
Time elapsed: 25.09 min
Epoch: 094/100 | Batch 000/021 | Gen/Dis Loss: 2.1225/0.6943
Epoch: 094/100 | Batch 010/021 | Gen/Dis Loss: 2.0170/0.6552
Epoch: 094/100 | Batch 020/021 | Gen/Dis Loss: 2.2062/0.7244
Time elapsed: 25.35 min
Epoch: 095/100 | Batch 000/021 | Gen/Dis Loss: 2.0828/0.6862
Epoch: 095/100 | Batch 010/021 | Gen/Dis Loss: 1.9799/0.6845
Epoch: 095/100 | Batch 020/021 | Gen/Dis Loss: 2.1420/0.6561
Time elapsed: 25.62 min
Epoch: 096/100 | Batch 000/021 | Gen/Dis Loss: 2.0417/0.6428
Epoch: 096/100 | Batch 010/021 | Gen/Dis Loss: 2.0072/0.6607
Epoch: 096/100 | Batch 020/021 | Gen/Dis Loss: 2.0117/0.7040
Time elapsed: 25.88 min
Epoch: 097/100 | Batch 000/021 | Gen/Dis Loss: 2.0211/0.6948
Epoch: 097/100 | Batch 010/021 | Gen/Dis Loss: 2.0020/0.7140
Epoch: 097/100 | Batch 020/021 | Gen/Dis Loss: 2.2473/0.6349
Time elapsed: 26.15 min
Epoch: 098/100 | Batch 000/021 | Gen/Dis Loss: 2.0419/0.7197
Epoch: 098/100 | Batch 010/021 | Gen/Dis Loss: 1.9808/0.6849
Epoch: 098/100 | Batch 020/021 | Gen/Dis Loss: 1.9740/0.7502
Time elapsed: 26.41 min
Epoch: 099/100 | Batch 000/021 | Gen/Dis Loss: 2.0307/0.7028
Epoch: 099/100 | Batch 010/021 | Gen/Dis Loss: 1.9097/0.6803
Epoch: 099/100 | Batch 020/021 | Gen/Dis Loss: 2.0404/0.6867
Time elapsed: 26.68 min
Epoch: 100/100 | Batch 000/021 | Gen/Dis Loss: 2.0139/0.6762
Epoch: 100/100 | Batch 010/021 | Gen/Dis Loss: 2.0789/0.6683
Epoch: 100/100 | Batch 020/021 | Gen/Dis Loss: 2.1131/0.7311
Time elapsed: 26.95 min
Total Training Time: 26.95 min

Process finished with exit code 0

测试部分没做

猜你喜欢

转载自blog.csdn.net/weixin_48320163/article/details/129285075