Ejemplo n.º 1
0

for ex_name in ['random.goal']:
    random.seed(0)

    # instanciating the environment
    env_name, env_cfg = envs.kin(dim=DIM, limit=LIMIT)
    env = environments.Environment.create(env_cfg)

    # instanciating the explorer
    ex_cfg = exs.catalog[ex_name]._deepcopy()
    ex_cfg.m_channels = env.m_channels
    ex_cfg.s_channels = env.s_channels
    ex = explorers.Explorer.create(ex_cfg)

    # running exploration
    explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N, verbose=True)

    # making graphs
    for t1, t2 in [(0, 100), (100, N)]:
        alpha = 1.0 if t2 == 100 else 0.25
        graphs.posture_random(env, explorations[t1:t2], n=10,
                              alpha=0.75, radius_factor=0.35)
        graphs.hold(True)
        graphs.bokeh_spread(env.s_channels, s_vectors=s_vectors[:t2],
                            e_radius=1.5, e_alpha=alpha,
                            x_range=(-1.05, 1.05), y_range=(-1.05, 1.05),
                            title='{}::{}'.format(ex_name, env_name))

graphs.show()
Ejemplo n.º 2
0
ex_cfg = explorers.MetaExplorer.defcfg._deepcopy()
ex_cfg.eras = (MB, None)
ex_cfg.weights = ((1.0, 0.0), (0.0, 1.0))
ex_cfg.fallback = 0

ex_cfg.ex_0 = explorers.ReuseExplorer.defcfg._deepcopy()
ex_cfg.ex_0.reuse.res = RES
ex_cfg.ex_1 = explorers.RandomGoalExplorer.defcfg._deepcopy()
ex_cfg.ex_1.learner = exs.catalog['random.goal'].ex_1.learner._deepcopy()

# instanciating the environment and the Explorer
ex_cfg.m_channels = env.m_channels
ex_cfg.s_channels = env.s_channels
ex = explorers.Explorer.create(ex_cfg, datasets=[dataset])

explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

graphs.output_file('c5_fig5_2.3.4_reuse.html')

# Graph of reused effects in first env
s_vectors0 = []
for explo in explorations[:MB]:
    feedback = env0.execute(explo[0]['m_signal'])
    s_vectors0.append(
        explorers.tools.to_vector(feedback['s_signal'], env0.s_channels))

graphs.spread(env.s_channels,
              s_vectors=s_vectors0[:MB],
              e_radius=3.0,
              e_alpha=1.0,
              e_color='#DF6464',
Ejemplo n.º 3
0
# instanciating the environment, and the Meshgrid
env_name, env_cfg = envs.kin(dim=DIM, limit=150)
env = environments.Environment.create(env_cfg)

ex_cfg = exs.catalog['random.goal']._deepcopy()
ex_cfg.eras = (MB, None)
ex_cfg.m_channels = env.m_channels
ex_cfg.s_channels = env.s_channels
ex = explorers.Explorer.create(ex_cfg)

mesh = explorers.ExplorerMeshGrid({'res': RES}, env.s_channels, env.m_channels)

# running the exploration
explorations, s_vectors, s_goals = factored.run_exploration(env,
                                                            ex,
                                                            N,
                                                            mesh=mesh)
mesh_picks = pick(mesh)

# Spread Graph
for t in [MB, 200, 400, N]:
    alpha = 1.0 if t != N else 0.5
    graphs.spread(mesh.s_channels,
                  s_vectors=s_vectors[:t],
                  grid=False,
                  e_radius=1.5,
                  e_alpha=alpha,
                  title='first arm - {} steps'.format(t))
    # graphs.hold(True)
    # if t == N:
    #     graphs.bokeh_spread(mesh.s_channels, s_vectors=[tools.to_vector(s, mesh.s_channels) for m, s in mesh_picks],
Ejemplo n.º 4
0
DIM = 20
N   = 5000


# preparing graphs
graphs.output_file('ddmab.html')

for disturb in [0.001, 0.002, 0.05, 0.5]:
    random.seed(0)

    # instanciating the environment
    env_name, env_cfg = envs.kin(dim=DIM, limit=150)
    env = environments.Environment.create(env_cfg)

    # instanciating the explorer
    ex_cfg = ddmab_ex.ex_cfg._deepcopy()
    ex_cfg.ex_1.learner.m_disturb = disturb
    ex_cfg.m_channels = env.m_channels
    ex_cfg.s_channels = env.s_channels
    ex = explorers.Explorer.create(ex_cfg)

    # running the exploration
    explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

    # making graphs
    for i, weights in enumerate(ex.weight_history['data']):
        ex.weight_history['data'][i] = [1000*w for w in weights]
    graphs.adapt_graphs(ex.cfg, explorations, s_vectors, ex.weight_history, title='{}'.format(disturb))

graphs.show()