Training your Agent
When you have finished building your agent, it is time to begin training.
The train_iters
parameter defines the number of training cycles in your training session. One training cycle is typically about 1000 agent decisions.
The runtime.train(agent, )
method call invokes the training for your agent.
python
runtime.train(agent, train_iters=500)
After we add this call, we have all the required pieces (sensors, perceptors, scenarios, and skills) of our agent and are ready to train.
python
from composabl import Agent, Skill, Sensor, Perceptor, Scenario, Runtime
from .teaching import IncrementTeacher, DecrementTeacher, TargetTeacher
from .scenarios import increment_scenarios, decrement_scenarios, target_scenarios
from .sensors import sensors
from .perceptors import perceptors
increment_skill = Skill("increment", IncrementTeacher)
for scenario_dict in increment_scenarios:
scenario = Scenario(scenario_dict)
increment_skill.add_scenario(scenario)
decrement_skill = Skill("decremement", DecrementTeacher)
for scenario_dict in decrement_scenarios:
scenario = Scenario(scenario_dict)
decrement_skill.add_scenario(scenario)
target_skill = Skill("target", TargetTeacher)
for scenario_dict in target_scenarios:
scenario = Scenario(scenario_dict)
target_skill.add_scenario(scenario)
config = {
"target": {
"docker": {
"image": "composabl/sim-demo:latest"
}
},
"env": {
"name": "sim-demo",
},
"license": "<This is your license key>",
"training": {},
}
runtime = Runtime(config)
agent = Agent()
agent.add_sensors(sensors)
agent.add_perceptors(perceptors)
agent.add_skill(increment_skill)
agent.add_skill(decrement_skill)
agent.add_selector_skill(target_skill, [increment_skill, decrement_skill], fixed_order=False, fixed_order_repeat=True)
runtime.train(agent, train_iters=1000)
Call the agent.py
Python file from the command line to start training.
bash
python agent.py