Open colourfulspring opened 1 year ago
Same issue It appears to be related to a mismatch in the passed parameters. One potential, albeit unsafe, solution would be to simply removeself.num_agents
.
OK, thanks!
I found another piece of code similar with this problem. Code snippet onpolicy/runner/shared/base_runner.py, line 90~93 are as follows
if self.algorithm_name == "mat" or self.algorithm_name == "mat_dec":
self.trainer = TrainAlgo(self.all_args, self.policy, self.num_agents, device = self.device)
else:
self.trainer = TrainAlgo(self.all_args, self.policy, device = self.device)
The code define TrainAlgo together with on-policy/onpolicy/runner/shared/base_runner.py, line 66~71 are
if self.algorithm_name == "mat" or self.algorithm_name == "mat_dec":
from onpolicy.algorithms.mat.mat_trainer import MATTrainer as TrainAlgo
from onpolicy.algorithms.mat.algorithm.transformer_policy import TransformerPolicy as Policy
else:
from onpolicy.algorithms.r_mappo.r_mappo import R_MAPPO as TrainAlgo
from onpolicy.algorithms.r_mappo.algorithm.rMAPPOPolicy import R_MAPPOPolicy as Policy
The TrainAlgo class has a very similar definition compared with the Policy class. Here the author just use an if statement to solve this problem. I think the aforementioned problem can be solved by add an if statement at the calling of Policy's constructor, too. Maybe one possible solution is changing on-policy/onpolicy/runner/shared/base_runner.py, line 80~85 to
if self.algorithm_name == "mat" or self.algorithm_name == "mat_dec":
self.policy = Policy(self.all_args, self.envs.observation_space[0], share_observation_space, self.envs.action_space[0], self.num_agents, device = self.device)
else:
self.policy = Policy(self.all_args, self.envs.observation_space[0], share_observation_space, self.envs.action_space[0], device = self.device)
I run ./onpolicy/scripts/train_mpe_scripts/train_mpe_spread.sh after change 'algo' to mappo and user_name to my wandb user name in train_mpe_spread.sh. My train_mpe_spread.sh is as follows:
Then I got an error
I found on-policy/onpolicy/runner/shared/base_runner.py, line 66~71 choose R_MAPPOPolicy as Policy:
The constructor of R_MAPPOPolicy is
but on-policy/onpolicy/runner/shared/base_runner.py, line 80~85 provide incompatible arguments to the constructor of R_MAPPOPolicy. The second last one is redundant.
What should I do? Thanks!