Exemplo n.º 1
0
print('{} training images'.format(len(train_HRimages)))
print('{} testing images'.format(len(test_HRimages)))

HR_loader = torch.utils.data.DataLoader(
    train_HRimages, shuffle=False, batch_size=batch_size)  #, pin_memory=cuda)
LR_loader = torch.utils.data.DataLoader(
    train_LRimages, shuffle=False, batch_size=batch_size)  #, pin_memory=cuda)

lossfunc = torch.nn.SmoothL1Loss()
#lossfunc = torch.nn.MSELoss()
TV_weight = 0  #1.e-4
SL_weight = 0  #1.e-4

num_epochs = 50
tvloss = lf.TVLoss(TV_weight)
styleloss = lf.StyleLoss(SL_weight)


def train(model):
    model.train()
    if cuda:
        model = model.cuda()

    epoch_loss = []
    epoch_psnr = []
    all_loss = []
    optimizer_name = torch.optim.Adam
    #lr = 0.001
    w_decay = 0  #1.0e-4
    optimizer = optimizer_name(model.parameters(), lr=lr, weight_decay=w_decay)
    gamma = 0.97
Exemplo n.º 2
0
train_HRimages = HRimages[0:Ntrain]
test_HRimages = HRimages[Ntrain:Ntrain + Ntest]
train_LRimages = LRimages[0:Ntrain]
test_LRimages = LRimages[Ntrain:Ntrain + Ntest]
print('{} training images'.format(len(train_HRimages)))
print('{} testing images'.format(len(test_HRimages)))

HR_loader = torch.utils.data.DataLoader(
    train_HRimages, shuffle=False, batch_size=batch_size)  #, pin_memory=cuda)
LR_loader = torch.utils.data.DataLoader(
    train_LRimages, shuffle=False, batch_size=batch_size)  #, pin_memory=cuda)

lossfunc = torch.nn.SmoothL1Loss()
#lossfunc = torch.nn.MSELoss()
TV_weight = 5.e-5
styleloss = lf.StyleLoss(1.0e-14)

num_epochs = 100


def train(model):
    model.train()
    if cuda:
        model = model.cuda()

    epoch_loss = []
    all_loss = []
    optimizer_name = torch.optim.Adam
    lr = 0.001
    w_decay = 1.0e-5
    optimizer = optimizer_name(model.parameters(), lr=lr, weight_decay=w_decay)