예제 #1
0
    loss_value2 = []
    # loss_img_value = []
    scheduler.step()

    for i_batch, sample in enumerate(dataloader):

        data = sample['frames'].squeeze(0).cuda(gpu_id)
        flows = sample['flows'].squeeze(0)

        expectedOut = Variable(data)
        inputData = Variable(data[:, 0:FRA, :])
        optimizer.zero_grad()

        y = data[:, 0:FRA + PRE, :].data

        dct = model.forward(inputData)
        dct1 = model1.forward(inputData)
        dct2 = model2.forward(inputData)
        '''Plot DCT coefficients'''
        coef = dct.data
        coef1 = dct1.data
        coef2 = dct2.data
        coefP = torch.t(coef[0, :, :]).data.cpu().detach().numpy()
        coefP1 = torch.t(coef1[0, :, :]).data.cpu().detach().numpy()
        coefP2 = torch.t(coef2[0, :, :]).data.cpu().detach().numpy()
        coefR = torch.t(y[0, :, :])

        maxcp, idxcp = coefR[:, 0].max(0)
        plt.figure()
        t = np.arange(0, FRA + PRE, 1)
        gt, = plt.plot(t, coefR[idxcp].data.cpu().detach().numpy(), label="GT")
예제 #2
0
for epoch in range(start_epoch, EPOCH + 1):
    loss_value = []
    loss_valueR = []
    schedulerrgb.step()
    for i_batch, sample in enumerate(dataloader):

        data = sample['alframes'].squeeze(0).cuda(gpu_id)
        dataori = sample['frames'].squeeze(0).cuda(gpu_id)
        of = sample['of'].squeeze(0).cuda(
            gpu_id)  #could be done in different GPU's
        ofori = sample['ofori'].squeeze(0)  #.cuda(gpu_id)

        expectedOut = Variable(data)
        inputData = Variable(data[:, 0:N_FRAME, :])
        optimizerrgb.zero_grad()
        output = modelrgb.forward(inputData)

        with torch.no_grad():
            ofout = ofmodel.forward(Variable(of[:, 0:FRA, :]))

        out = warp(output[:, FRA, :].view(3, x_fra, y_fra).unsqueeze(0),
                   ofout[:, FRA, :].view(2, x_fra, y_fra).unsqueeze(0))
        showframes(
            out.view(3, x_fra, y_fra).unsqueeze(0).unsqueeze(2),
            expectedOut[:, N_FRAME, :].view(3, x_fra,
                                            y_fra).unsqueeze(0).unsqueeze(2),
            1, '')

        # lossR = loss_mse(output[:, FRA, :], expectedOut[:, FRA, :])
        loss = loss_mse(output[:, FRA, :], expectedOut[:, FRA, :]) \
               + loss_mse(output[:, 0:FRA, :], expectedOut[:, 0:FRA, :])/(2*FRA) # probar amb expectedout com a GT
예제 #3
0
파일: train.py 프로젝트: sadjadasghari/DYAN
            torch.cat(c_list_VI, out=c_VI)
            C[3, :, :] = c_VI.permute(1, 2, 0, 3).reshape(-1, x_fra * y_fra * CLen).unsqueeze(0)

            C = C.permute(1,0,2).reshape(-1, x_fra * y_fra * CLen * 4).unsqueeze(0)
            C_t.append(C)
            print(len(C_t))

            print('Time for spacial encoding in time T: ', time.time() - t0_sp)


        ## REGULAR DYAN
        Ctens_t = torch.Tensor(FRA, 2, CLen*x_fra*y_fra*4).cuda(gpu_id)
        torch.cat(C_t, out=Ctens_t)

        print(Ctens_t.shape, type(Ctens_t))
        Cpred = model_ti.forward(Ctens_t.permute(1,0,2))

        print('Time per forward: ', time.time() - t0_epoch)

        ## GPU LACKS MEMORY - TOO MUCH TIME --> ENCODERS COULD BE PARALLELIZED
        sys.exit()




    loss_val = np.mean(np.array(loss_value))

    ## Checkpoint + prints
    if epoch % saveEvery ==0 :
        save_checkpoint({	'epoch': epoch + 1,
                            'state_dict': model.state_dict(),