예제 #1
0
파일: train.py 프로젝트: Czworldy/GP
logger = SummaryWriter(log_dir=log_path)

model = ModelMixStyleWithV().to(device)
optimizer = torch.optim.Adam(model.parameters(),
                             lr=3e-4,
                             weight_decay=opt.weight_decay)

param = parse_yaml_file_unsafe('./param_oxford.yaml')
train_loader = DataLoader(DIVADataset(param, mode='train', opt=opt),
                          batch_size=opt.batch_size,
                          shuffle=False,
                          num_workers=opt.n_cpu)
train_samples = iter(train_loader)

param = parse_yaml_file_unsafe('./param_kitti.yaml')
eval_trajectory_dataset = KittiDataset(param, 'eval', opt)  #2
dataloader_eval = DataLoader(eval_trajectory_dataset,
                             batch_size=1,
                             shuffle=False,
                             num_workers=1)
eval_samples = iter(dataloader_eval)

criterion = nn.MSELoss().to(device)
criterion_l1 = nn.SmoothL1Loss().to(device)
trajectory_criterion = torch.nn.MSELoss().to(device)


def show_traj_with_uncertainty(fake_traj,
                               real_traj,
                               step,
                               model_index,
예제 #2
0
    torch.load(
        'result/saved_models/train-gan-costmap-vector16-01/generator_6000.pth')
)

trajectory_criterion = torch.nn.MSELoss().to(device)

e_optimizer = torch.optim.Adam(encoder.parameters(),
                               lr=opt.lr,
                               weight_decay=opt.weight_decay)

# param = parse_yaml_file_unsafe('./param_oxford.yaml')
# train_loader = DataLoader(OursDataset(param, mode='train', opt=opt), batch_size=opt.batch_size, shuffle=False, num_workers=opt.n_cpu)
# train_samples = iter(train_loader)

param = parse_yaml_file_unsafe('./param_kitti.yaml')
eval_loader = DataLoader(KittiDataset(param, mode='eval', opt=opt),
                         batch_size=1,
                         shuffle=False,
                         num_workers=1)
eval_samples = iter(eval_loader)


def show_traj(fake_traj, real_traj, t, step):
    fake_xy = fake_traj
    x = fake_xy[:, 0] * opt.max_dist
    y = fake_xy[:, 1] * opt.max_dist
    real_xy = real_traj
    real_x = real_xy[:, 0] * opt.max_dist
    real_y = real_xy[:, 1] * opt.max_dist

    max_x = 30.
예제 #3
0
trajectory_criterion = torch.nn.MSELoss().to(device)

latent_criterion = torch.nn.MSELoss().to(device)

e_optimizer = torch.optim.Adam(encoder.parameters(), lr=opt.lr, weight_decay=opt.weight_decay)

discriminator = Discriminator(input_dim=opt.vector_dim*2, output=1).to(device)
discriminator_criterion = nn.BCEWithLogitsLoss().to(device)
d_optimizer = torch.optim.Adam(discriminator.parameters(), lr=3e-4, weight_decay=opt.weight_decay)

param = parse_yaml_file_unsafe('./param_oxford.yaml')
train_loader = DataLoader(DIVADataset(param, mode='train', opt=opt), batch_size=opt.batch_size, shuffle=False, num_workers=opt.n_cpu)
train_samples = iter(train_loader)

param = parse_yaml_file_unsafe('./param_kitti.yaml')
eval_loader = DataLoader(KittiDataset(param, mode='eval', opt=opt), batch_size=1, shuffle=False, num_workers=1)
eval_samples = iter(eval_loader)

    
def show_traj(fake_traj, real_traj, t, step, img=None):
    fake_xy = fake_traj
    x = fake_xy[:,0]#*opt.max_dist
    y = fake_xy[:,1]#*opt.max_dist
    real_xy = real_traj
    real_x = real_xy[:,0]#*opt.max_dist
    real_y = real_xy[:,1]#*opt.max_dist

    max_x = 30.
    max_y = 30.
    
    fig = plt.figure(figsize=(7, 7))