In [1]:
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
import sys
sys.path.append('..')
import numpy as np
import deep_control as dc
Previously generated trajectories can be loaded with dc.data.load_trajectories
In [3]:
# The time column is automatically discarded
# For free landing we drop the 'x' column
col_names = ['t', 'm', #'x',
'vx', 'z', 'vz', 'theta', 'vtheta', 'T', 'Tl', 'Tr']
cols = [0,1, #2,
3,4,5,6,7,8,9,10]
In [4]:
trajs = dc.data.load_trajectories('data/main_thrusters/', col_names=col_names, cols=cols)
From the trajectories we can generate the training sets:
In [5]:
train_p = 0.9 # proportion of training data
x_train, y_train, x_test, y_test, idx_train = dc.data.create_training_data(trajs, train_p = train_p, n_outputs=3)
In [6]:
dc.nn.save_training_data([x_train, y_train, x_test, y_test, idx_train], "mass_thrusters")
We specify a model to train
In [7]:
model_description = {"data": "mass_thrusters",
"control": dc.nn.THRUST,
"nlayers": 3,
"units": 128,
"output_mode": dc.nn.OUTPUT_LOG,
"dropout": False,
"batch_size": 8,
"epochs": 32,
"lr": 0.001,
"input_vars" : 6,
"hidden_nonlinearity": "ReLu"}
In [9]:
dc.nn.train(model_description)