-
Notifications
You must be signed in to change notification settings - Fork 3
/
config_loco_ant_rnn.py
81 lines (66 loc) · 3.45 KB
/
config_loco_ant_rnn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
# coding=utf8
# File: config.py
import os
import math
import random
import numpy
from envs.env_ant import AntTask
from envs.env_ant import gen_task as gen_single
from envs.env_ant import output_to_action
from envs.env_ant import obs_to_input
from epann.utils import categorical
from models_zoo import ModelRNNBase1, ModelLSTMBase1, ModelFCBase2
from models_zoo import ModelPRNNPreMod, ModelPRNNAfterMod, ModelPRNNNoMod
from models_zoo import ModelPFCPreMod, ModelPFCAfterMod, ModelPFCNoMod
from gen_train_test_patterns import import_ants
root = "./results"
directory = root + "/workspace_loco_rnn/"
# Model Structure for EPRNN
#model = ModelFCBase2(input_shape=(38,), output_shape=(8,), hidden_size=64, output_activation="tanh", initialize_settings='R', init_scale=0.05)
#model = ModelLSTMBase1(input_shape=(38,), output_shape=(8,), hidden_size=64, extra_hidden_size=64, output_activation="softmax", init_scale=0.05)
model = ModelRNNBase1(input_shape=(38,), output_shape=(8,), hidden_size=64, output_activation="none", initialize_settings='R', init_scale=0.05)
#model = ModelPFCNoMod(input_shape=(15,), output_shape=(5,), hidden_size=64, output_activation="none", initialize_settings='R', hebbian_type=3, init_scale=0.05)
#model = ModelPFCPreMod(input_shape=(15,), output_shape=(5,), hidden_size=64, output_activation="none", initialize_settings='R', hebbian_type=3, init_scale=0.05)
#model = ModelPFCAfterMod(input_shape=(15,), output_shape=(5,), hidden_size=64, output_activation="none", initialize_settings='R', hebbian_type=3, init_scale=0.05)
#model = ModelPRNNNoMod(input_shape=(15,), output_shape=(5,), hidden_size=64, output_activation="none", initialize_settings='R', hebbian_type=3, init_scale=0.05)
#model = ModelPRNNPreMod(input_shape=(15,), output_shape=(5,), hidden_size=64, output_activation="none", initialize_settings='R', hebbian_type=3, init_scale=0.05)
# Hebbian-Type: 1. alpha ABCD; 2. Eligibility Traces; 3. Decomposed Plasticity; 4. Evolving & Merging
#model = ModelPRNNAfterMod(input_shape=(38,), output_shape=(8,), hidden_size=64, output_activation="none", initialize_settings='R', hebbian_type=3, init_scale=0.05)
# Refer to config_SeqPred_task.py for other configurations
#If no load_model is specified, the model is random initialized
#load_model = root + "demo/models/model.maze15_prnn64_aftermod.dat"
load_model = root + "/workspace_loco_rnn/models/model.000300.dat"
#Address for xparl servers, do "xparl start " in your server
#server = "10.216.186.20:8010"
server = "localhost:8010"
#True Batch size = Actor_number * batch_size
actor_number = 380
batch_size = 1
task_sub_iterations = 1
inner_rollouts = [(0.36, "TEST", True), (0.6, "TEST", True), (1.0, "TEST", True)]
#The task pattern are kept still for that much steps
pattern_retain_iterations = 1
#Select the inner-loop type, for PRNN / RNN / LSTM / EPMLP select "forward", for ES-MAML select "policy_gradient_continuous"
adapt_type = "forward"
ent_factor = 1.0e-6
evolution_pool_size = 360
evolution_topk_size = 180
# CMA-ES initial noise variance
evolution_step_size = 0.01
# CMA-ES hyper-parameter
evolution_lr = 0.02
# Model Saving Intervals
save_iter = 300
# Maximum Iterations
max_iter = 15000
# Intervals for meta-testing
test_iter = 50
#Sampled Tasks for meta-training
def train_patterns(n_step=0):
return import_ants(task_type="TRAIN", num=4)
#Sampled Tasks for meta-testing
def valid_patterns(pattern_number=64):
return import_ants(task_type="TRAIN", num=64)
def game():
return AntTask()