コード例 #1
0
import matplotlib.pyplot as plt
import mdp.offroad_grid as offroad_grid
import numpy as np
from network.hybrid_dilated import HybridDilated
from torch.autograd import Variable
import torch
from os.path import join
import scipy.io as sio
from loader.util import leastsq_circle, calc_sign
import seaborn as sns
import viz

# initialize parameters
grid_size = 80
discount = 0.9
model = offroad_grid.OffroadGrid(grid_size, discount)
n_states = model.n_states
n_actions = model.n_actions

net = HybridDilated(feat_out_size=25, regression_hidden_size=64)
net.init_weights()
net.load_state_dict(
    torch.load(join('example_data', 'example_weights6.34.pth'))['net_state'])
net.eval()


def load(grid_size):
    """ load sample demo input data"""
    mean_std = sio.loadmat(join('example_data', 'data_mean_std.mat'))
    data_mat = sio.loadmat(join('example_data', 'demo_input.mat'))
    feat = data_mat['feat']
コード例 #2
0
save_per_steps = 10
# resume = 'step8800-loss1.346111536026001.pth'
resume = None
exp_name = '4.0'
grid_size = 30
discount = 0.9
lr = 5e-3
n_train = 100000  # number of training traj

if not os.path.exists(os.path.join('exp', exp_name)):
    os.makedirs(os.path.join('exp', exp_name))

# host = os.environ['HOSTNAME']
# vis = visdom.Visdom(env='v{}-{}'.format(exp_name, host), server='http://128.2.176.221', port=4546)
vis = visdom.Visdom(env='main')
model = offroad_grid.OffroadGrid(grid_size, discount)  ## takes a long time to init
n_states = model.n_states
n_actions = model.n_actions

train_loader = kinematic_loader.KinematicLoader(grid_size=grid_size, n_traj=n_train)
train_loader = DataLoader(train_loader, num_workers=1, batch_size=1, shuffle=True)

net = SimpleFCN(input_size=4)
step = 0
nll_cma = 0
acc_test = 0

if resume is None:
    net.init_weights()
else:
    checkpoint = torch.load(os.path.join('exp', exp_name, resume))