File size: 1,291 Bytes
825cff4 | 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 | """
An example for creating and using the custom Config object.
"""
from robomimic.config.base_config import Config
if __name__ == "__main__":
# create config
config = Config()
config.train.batch_size = 100
config.train.learning_rate = 1e-3
config.algo.actor_network_size = [1000, 1000]
config.lock() # prevent accidental changes
# access config
print("batch_size={}".format(config.train.batch_size))
# the config is locked --- cannot add new keys or modify existing keys
try:
config.train.optimizer = "Adam"
except RuntimeError as e:
print(e)
# values_unlocked scope allows modifying values of existing keys, but not adding keys
with config.values_unlocked():
config.train.batch_size = 200
print("batch_size={}".format(config.train.batch_size))
# allow adding new keys to the config
with config.unlocked():
config.test.num_eval = 10
assert config.is_locked
assert config.test.is_locked
# read external config from a dict
ext_config = {
"train": {
"learning_rate": 1e-3
},
"algo": {
"actor_network_size": [1000, 1000]
}
}
with config.values_unlocked():
config.update(ext_config)
print(config) |