In [1]:
import sys
sys.path.append('..')
import deep_control as dc
import numpy as np
In [2]:
import matplotlib.pylab as plt
import seaborn as sns
%matplotlib inline
In [4]:
import pickle
In [5]:
[x_train, y_train, x_test, y_test, idx_train] = pickle.load(open('../traj/quadrotor_power.pic', 'rb'))
In [120]:
import time
def timeNN(networks, x_train):
iters = 100000
t0 = time.time()
m1,n1 = networks[0]
m2,n2 = networks[1]
for i in range(iters):
x = x_train[i]
x = dc.nn.preprocess(m1, x)
u1 = n1['pred'](x.reshape(1,-1))[0,0]
u2 = n2['pred'](x.reshape(1,-1))[0,0]
y = dc.nn.postprocess(m1, np.asarray([u1,u2]).reshape(1,-1))
tf = time.time()
print((tf-t0)/iters*1000, 'ms')
In [122]:
model_th = dc.nn.load_model('../nets/mass_clean/0/ReLu_outputLog_1_1104.model')
network_th = dc.nn.load_network(model_th, base_dir='../')
model_dth = dc.nn.load_model('../nets/mass_clean/1/ReLu_outputLog_1_1104.model')
network_dth = dc.nn.load_network(model_dth, base_dir='../')
networks = [(model_th,network_th),(model_dth,network_dth)]
print(model_th['nlayers'], ',', model_th['units'])
timeNN(networks, x_train)
In [124]:
model_th = dc.nn.load_model('../nets/mass_clean/0/ReLu_outputLog_4_64.model')
network_th = dc.nn.load_network(model_th, base_dir='../')
model_dth = dc.nn.load_model('../nets/mass_clean/1/ReLu_outputLog_4_64.model')
network_dth = dc.nn.load_network(model_dth, base_dir='../')
networks = [(model_th,network_th),(model_dth,network_dth)]
print(model_th['nlayers'], ',', model_th['units'])
timeNN(networks, x_train)
In [125]:
model_th = dc.nn.load_model('../nets/mass_clean/1/ReLu_outputLog_4_128.model')
network_th = dc.nn.load_network(model_th, base_dir='../')
model_dth = dc.nn.load_model('../nets/mass_clean/1/ReLu_outputLog_4_128.model')
network_dth = dc.nn.load_network(model_dth, base_dir='../')
networks = [(model_th,network_th),(model_dth,network_dth)]
print(model_th['nlayers'], ',', model_th['units'])
timeNN(networks, x_train)
In [126]:
model_th = dc.nn.load_model('../nets/mass_clean/1/ReLu_outputLog_4_256.model')
network_th = dc.nn.load_network(model_th, base_dir='../')
model_dth = dc.nn.load_model('../nets/mass_clean/1/ReLu_outputLog_4_256.model')
network_dth = dc.nn.load_network(model_dth, base_dir='../')
networks = [(model_th,network_th),(model_dth,network_dth)]
print(model_th['nlayers'], ',', model_th['units'])
timeNN(networks, x_train)
In [10]:
import time
def timeAMPL(model, x_train, nodes):
iters = 100
t0 = time.time()
for i in range(iters):
x = x_train[i]
conditions = {'n':nodes,
'vx': x[1],
'z': x[2],
'vz': x[3],
'theta': x[4],
'm': x[0]}
traj = dc.data.get_trajectory(model, conditions)
tf = time.time()
print((tf-t0)/iters*1000, 'ms')
In [ ]:
model = 'main_rw_mass'
In [6]:
[x_train, y_train, x_test, y_test, idx_train] = pickle.load(open('../traj/quadrotor_power.pic', 'rb'))
In [21]:
model = 'main_quadrotor_power'
In [22]:
nodes = 5
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [23]:
nodes = 20
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [24]:
nodes = 50
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [25]:
[x_train, y_train, x_test, y_test, idx_train] = pickle.load(open('../traj/quadrotor_time.pic', 'rb'))
model = 'main_quadrotor_time'
In [26]:
nodes = 5
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [27]:
nodes = 20
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [28]:
nodes = 50
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [30]:
[x_train, y_train, x_test, y_test, idx_train] = pickle.load(open('../traj/mass_thrusters.pic', 'rb'))
In [33]:
model = 'main_thrusters'
In [34]:
nodes = 5
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
nodes = 20
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
nodes = 50
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [36]:
[x_train, y_train, x_test, y_test, idx_train] = pickle.load(open('../traj/mass_clean.pic', 'rb'))
In [37]:
model = 'main_rw_mass'
nodes = 5
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
nodes = 20
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
nodes = 50
print(nodes)
timeAMPL('../SpaceAMPL/lander/hs/' + model + '.mod', x_train, nodes)
In [ ]: