encoder.load_state_dict(
    torch.load('./result/saved_models/il-uncertainty-02/encoder_119000.pth'))
generator.load_state_dict(
    torch.load('./result/saved_models/il-uncertainty-02/generator_119000.pth'))

criterion = torch.nn.MSELoss()
e_optimizer = torch.optim.Adam(encoder.parameters(),
                               lr=opt.lr,
                               weight_decay=opt.weight_decay)
g_optimizer = torch.optim.Adam(generator.parameters(),
                               lr=opt.lr,
                               weight_decay=opt.weight_decay)

train_loader = DataLoader(CostMapDataset(
    data_index=[1, 2, 3, 4, 5, 6, 7, 8, 9],
    opt=opt,
    dataset_path='/media/wang/DATASET/CARLA_HUMAN/town01/'),
                          batch_size=opt.batch_size,
                          shuffle=False,
                          num_workers=opt.n_cpu)
test_loader = DataLoader(CostMapDataset(
    data_index=[10],
    opt=opt,
    dataset_path='/media/wang/DATASET/CARLA_HUMAN/town01/'),
                         batch_size=1,
                         shuffle=False,
                         num_workers=1)
test_samples = iter(test_loader)


def test_traj_v(xs, ys, step):
Пример #2
0
start_point_criterion = torch.nn.MSELoss()
criterion = torch.nn.BCELoss()  #.to(device)
trajectory_criterion = torch.nn.MSELoss()
# e_optimizer = torch.optim.RMSprop(encoder.parameters(), lr=opt.lr, weight_decay=opt.weight_decay)
g_optimizer = torch.optim.RMSprop(generator.parameters(),
                                  lr=opt.lr,
                                  weight_decay=opt.weight_decay)
#g_optimizer = torch.optim.Adam(generator.parameters(), lr=opt.lr, weight_decay=opt.weight_decay)
d_optimizer = torch.optim.RMSprop(discriminator.parameters(),
                                  lr=opt.lr,
                                  weight_decay=opt.weight_decay)
#d_optimizer = torch.optim.Adam(discriminator.parameters(), lr=opt.lr, weight_decay=opt.weight_decay)

train_loader = DataLoader(CostMapDataset(
    data_index=[item for item in range(1, 10)],
    opt=opt,
    dataset_path='/media/wang/DATASET/CARLA_HUMAN/town01/'),
                          batch_size=opt.batch_size,
                          shuffle=False,
                          num_workers=opt.n_cpu)
test_loader = DataLoader(CostMapDataset(
    data_index=[10],
    opt=opt,
    dataset_path='/media/wang/DATASET/CARLA_HUMAN/town01/'),
                         batch_size=1,
                         shuffle=False,
                         num_workers=1)
# test_loader = DataLoader(CostMapDataset(data_index=[8], opt=opt, dataset_path='/media/wang/DATASET/CARLA/town01/'), batch_size=1, shuffle=False, num_workers=1)
test_samples = iter(test_loader)

Пример #3
0
os.makedirs('result/output2/%s' % opt.dataset_name, exist_ok=True)
if not opt.test_mode:
    logger = SummaryWriter(log_dir=log_path)
    write_params(log_path, parser, description)


generator = Generator(opt.vector_dim+2, output=2).to(device)
encoder = CNN(input_dim=1, out_dim=128).to(device)


criterion = torch.nn.MSELoss()
e_optimizer = torch.optim.Adam(encoder.parameters(), lr=opt.lr, weight_decay=opt.weight_decay)
g_optimizer = torch.optim.Adam(generator.parameters(), lr=opt.lr, weight_decay=opt.weight_decay)


train_loader = DataLoader(CostMapDataset(data_index=[1,2,3,4,5,6,7,8,9], opt=opt, dataset_path='/media/wang/DATASET/CARLA_HUMAN/town01/'), batch_size=opt.batch_size, shuffle=False, num_workers=opt.n_cpu)
test_loader = DataLoader(CostMapDataset(data_index=[10], opt=opt, dataset_path='/media/wang/DATASET/CARLA_HUMAN/town01/'), batch_size=1, shuffle=False, num_workers=1)
test_samples = iter(test_loader)
    
def test_traj_v(xs, ys, step):
    fig = plt.figure(figsize=(7, 7))
    ax1 = fig.add_subplot(111)
    for i in range(len(xs)):
        ax1.plot(xs[i], ys[i], label=str(round(0.8*i, 1)), linewidth=5)
    ax1.set_xlabel('Forward/(m)')
    ax1.set_ylabel('Sideways/(m)')  
    ax1.set_xlim([0., 40])
    ax1.set_ylim([-20, 20])
    #plt.legend(loc='lower right')
    #plt.legend(loc='lower right', bbox_to_anchor=(1.0, 0.))
    plt.legend(loc='center', bbox_to_anchor=(0.9, 0.5))