In [1]:
from explauto import Experiment
from explauto.experiment import make_settings
random_goal_babbling = make_settings(environment='simple_arm', environment_config = 'mid_dimensional',
babbling_mode='goal',
interest_model='discretized_progress',
sensorimotor_model='nearest_neighbor',
)
expe = Experiment.from_settings(random_goal_babbling)
In [2]:
expe.run(1000)
In [3]:
%pylab inline
ax = axes()
title(('Random goal babbling'))
expe.log.scatter_plot(ax, (('sensori', [0, 1]),))
expe.log.scatter_plot(ax, (('choice', [0, 1]),), marker='+', color='red')
#expe.log.scatter_plot(ax, (('testcases', [0, 1]),), marker='o', color='green')
legend(['reached hand positions', 'chosen goals'])
Out[3]:
In [4]:
ax = axes()
# Define the line and plot it:
x = 0.8
y_a = 0.5
y_b = -0.5
ax.plot([x, x], [y_a, y_b], color='red')
expe.ag.sensorimotor_model.mode = 'exploit'
# for 10 points equidistantly spaced on the line, perform inverse prediction and plot:
for y in linspace(-0.5, 0.5, 10):
m = expe.ag.sensorimotor_model.inverse_prediction([x, y])
expe.env.plot_arm(ax, m)
In [5]:
expe.log.save('test.pkl', 'pickle')
In [6]:
del expe
In [10]:
from explauto.experiment import ExperimentLog
logs = ExperimentLog.from_file('test.pkl', 'pickle')
In [11]:
from explauto import Experiment
from explauto.experiment import make_settings
random_goal_babbling = make_settings(environment='simple_arm', environment_config = 'mid_dimensional',
babbling_mode='goal',
interest_model='discretized_progress',
sensorimotor_model='nearest_neighbor',
)
expe = Experiment.from_settings(random_goal_babbling)
In [12]:
expe.fast_forward(logs)
They should be the same as before pickeling
In [13]:
ax = axes()
title(('Random goal babbling'))
expe.log.scatter_plot(ax, (('sensori', [0, 1]),))
expe.log.scatter_plot(ax, (('choice', [0, 1]),), marker='+', color='red')
#expe.log.scatter_plot(ax, (('testcases', [0, 1]),), marker='o', color='green')
legend(['reached hand positions', 'chosen goals'])
Out[13]:
In [14]:
ax = axes()
# Define the line and plot it:
x = 0.8
y_a = 0.5
y_b = -0.5
ax.plot([x, x], [y_a, y_b], color='red')
expe.ag.sensorimotor_model.mode = 'exploit'
# for 10 points equidistantly spaced on the line, perform inverse prediction and plot:
for y in linspace(-0.5, 0.5, 10):
m = expe.ag.sensorimotor_model.inverse_prediction([x, y])
expe.env.plot_arm(ax, m)