コード例 #1
0
###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_velocity_config.json') as json_data_file:
    il_config = json.load(json_data_file)

file_path = il_config['file_path'] + il_config['experiment_name']

il_config['model'] = DecisionTreeClassifier(max_depth=4)

#Trainer class
trainer = Trainer(fluids_config, il_config)

#Plotter class
plotter = Plotter(file_path)
stats = []

for i in range(il_config['num_iters']):
    #Collect demonstrations
    trainer.collect_supervisor_rollouts()
    #update model
    trainer.train_model()
    #Evaluate Policy
    stats.append(trainer.get_stats())

#Save plots
plotter.save_plots(stats)
コード例 #2
0
###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_covariate_config.json') as json_data_file:
    il_config = json.load(json_data_file)

fluids_config['environment']['visualize'] = False

###### SELECT PARAMETER  #################
il_config['time_horizon'] = 5
il_config['num_sup_rollouts'] = 4
il_config['experiment_name'] = il_config[
    'trial_name'] + 'save_unit_test_' + str(rand.uniform())

trainer = Trainer(fluids_config, il_config)

trainer.collect_supervisor_rollouts()

trainer.train_model()

train_sup = trainer.il_learn.get_train_error()
loss_sup, _ = trainer.il_learn.get_test_error()

assert (train_sup >= 0.0)
assert (loss_sup >= 0.0)
コード例 #3
0
import json
import glob
from il_fluids.core import Trainer
import os.path

###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_covariate_config.json') as json_data_file:
    il_config = json.load(json_data_file)

fluids_config['environment']['visualize'] = True

###### SELECT PARAMETER  #################
il_config['time_horizon'] = 5
il_config['num_sup_rollouts'] = 4
il_config['num_iters'] = 1
il_config['experiment_name'] = il_config[
    'trial_name'] + 'save_unit_test_' + str(rand.uniform())

file_path = il_config['file_path'] + il_config['experiment_name']

trainer = Trainer(fluids_config, il_config)

trainer.train_robot()
assert (os.path.isfile(file_path + '/plots/reward.png'))
コード例 #4
0
import os.path

###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_covariate_config.json') as json_data_file:
    il_config = json.load(json_data_file)

fluids_config['environment']['visualize'] = False

###### SELECT PARAMETER  #################
il_config['time_horizon'] = 5
il_config['num_sup_rollouts'] = 4
il_config['num_iters'] = 1
il_config['experiment_name'] = il_config[
    'trial_name'] + 'save_unit_test_' + str(rand.uniform())

file_path = il_config['file_path'] + il_config['experiment_name']

trainer = Trainer(fluids_config, il_config)

trainer.set_tracker(BaseTracker)

trainer.train_robot()

assert (os.path.isfile(file_path + '/tracker/initial_state.npy'))
コード例 #5
0
import cProfile
import time
import numpy as np
import numpy.linalg as LA
import json
from il_fluids.core import Trainer

from sklearn.tree import DecisionTreeClassifier

from il_fluids.data_protocols import *

###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_covariate_config.json') as json_data_file:
    il_config = json.load(json_data_file)

fluids_config['environment']['visualize'] = False
il_config['time_horizon'] = 5
###### SELECT MODEL #################

trainer = Trainer(fluids_config, il_config)

rollout = trainer.rollout_supervisor()

assert (len(rollout) == 5)
コード例 #6
0
with open('configs/il_covariate_two_config.json') as json_data_file:
    il_config = json.load(json_data_file)

###### SELECT MODEL #################
il_config['model'] = DecisionTreeClassifier(max_depth=10)

fluids_config['environment']['visualize'] = True

# ###RUN BEHAVIOR CLONING############
# il_config['experiment_name']  = il_config['trial_name'] + "_30_noise_injection"

# trainer = Trainer(fluids_config,il_config)

# dcp = DART()
# dcp.noise = 0.3
# trainer.set_data_protocol(dcp)
# trainer.train_robot()

il_config['experiment_name'] = il_config['trial_name'] + "_10_noise_neural"

trainer = Trainer(fluids_config, il_config)

trainer.set_data_protocol(DART())
trainer.train_robot()

# il_config['experiment_name']  = il_config['trial_name'] + "_bc"

# trainer = Trainer(fluids_config,il_config)

# trainer.train_robot()
コード例 #7
0
import gym
import gym_urbandriving as uds
import cProfile
import time
import numpy as np
import numpy.linalg as LA
import json
from il_fluids.core import Trainer
from il_fluids.core import Learner
from il_fluids.core import Plotter

###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_velocity_config.json') as json_data_file:
    il_config = json.load(json_data_file)

file_path = il_config['file_path'] + il_config['experiment_name']

#Trainer class
trainer = Trainer(fluids_config, il_config)

trainer.train_model()

trainer.get_stats()
コード例 #8
0
import json
import glob
from il_fluids.core import Trainer

###A script to test behavior cloning

#Config for FLUIDS simulator
with open('configs/fluids_config.json') as json_data_file:
    fluids_config = json.load(json_data_file)

#Config for Imitation Learning Experiment
with open('configs/il_covariate_config.json') as json_data_file:
    il_config = json.load(json_data_file)

fluids_config['environment']['visualize'] = False

###### SELECT PARAMETER  #################
il_config['time_horizon'] = 5
il_config['num_sup_rollouts'] = 4
il_config['experiment_name'] = il_config[
    'trial_name'] + 'save_unit_test_' + str(rand.uniform())

trainer = Trainer(fluids_config, il_config)

trainer.collect_supervisor_rollouts()

trainer.train_model()

loss_robot, reward, _ = trainer.evaluate_policy()

assert (loss_robot >= 0.0)