base¶
BaseAgent & its config.
- class cneuromax.fitting.neuroevolution.agent.base.BaseAgentConfig(env_transfer='${config.env_transfer}', fit_transfer='${config.fit_transfer}', mem_transfer='${config.mem_transfer}')[source]¶
Bases:
objectHolds
BaseAgentconfig values.- Parameters:
env_transfer (
bool, default:'${config.env_transfer}') – Seeenv_transfer.fit_transfer (
bool, default:'${config.fit_transfer}') – Seefit_transfer.mem_transfer (
bool, default:'${config.mem_transfer}') – Seemem_transfer.
- class cneuromax.fitting.neuroevolution.agent.base.BaseAgent(config, pop_idx, *, pops_are_merged)[source]¶
Bases:
ABCRoot Neuroevolution agent class.
From an algorithmic perspective, we make use of 50% truncation selection, meaning that the top 50% of agents in terms of fitness score are selected and will produce two children agents each.
From an implementation perspective,
pop_sizeinstances of this class will be created upon initialization. Whenever an agent is selected, a copy of this object will be created and sent to a MPI process in possession of a non-selected agent. Both this original instance and the copy sent to the other process will be mutated in-place (meaning no new instance will be created).It might therefore be useful to sometimes consider this class as an
AgentContainerclass rather than anAgentclass.- Parameters:
pop_idx (
int) – The agent’s population index. An index of0means that the agent is in the generator population while an index of1means that the agent is in the discriminator population.pops_are_merged (
bool) – Seepop_merge.
- config¶
- Type:
- is_other_role_in_other_pop¶
Whether the agent is the other role in the other population. If the two populations are merged (see
pops_are_merged), then an agent is both a generator and a discriminator. It is a generator/discriminator in this population while it is a discriminator/generator in the other population. Such type of agent needs to accomodate this property through its network architecture.- Type:
- total_num_steps¶
The total number of steps taken by the agent and all of its predecessors.
- Type:
- curr_eval_num_steps¶
The number of steps taken by the agent during the current evaluation.
- Type:
- saved_env¶
The torchrl environment instance to resume from (only set if
env_transferisTrue).- Type:
- saved_env_out¶
The latest output from the environment to resume from (only set if
env_transferisTrue).- Type:
tensordict.Tensordict
- curr_episode_score¶
The current episode score (only set if
env_transferisTrue).- Type:
- curr_episode_num_steps¶
The number of steps taken in the current episode (only set if
env_transferisTrue).- Type:
- continual_fitness¶
The agent’s fitness in addition to all of its predecessors’ fitnesses (only set if
fit_transferisTrue).- Type: