// measure data loading time
data_time.update(time.time() - end)
target = target.cuda(async=True)
input = [j.cuda() for j in input]
input_var = torch.autograd.Variable(torch.cat(input,1))
target_var = torch.autograd.Variable(target)
// compute output
output = model(input_var)
if args.sparse:
// Since Target pooling is not very precise when sparse,
// take the highest resolution prediction and upsample it instead of downsampling target
h, w = target_var.size()[-2:]
output = [torch.nn.functional.upsample(output[0], (h,w)), *output[1:]]
loss = multiscaleEPE(output, target_var, weights=args.multiscale_weights, sparse=args.sparse)
flow2_EPE = args.div_flow * realEPE(output[0], target_var, sparse=args.sparse)
// record loss and EPE
losses.update(loss.data[0], target.size(0))
train_writer.add_scalar("train_loss", loss.data[0], n_iter)
flow2_EPEs.update(flow2_EPE.data[0], target.size(0))
// compute gradient and do optimization step
After Change
flow2_EPE = args.div_flow * realEPE(output[0], target, sparse=args.sparse)
// record loss and EPE
losses.update(loss.item(), target.size(0))
train_writer.add_scalar("train_loss", loss.item(), n_iter)
flow2_EPEs.update(flow2_EPE.item(), target.size(0))
// compute gradient and do optimization step