Replicable-MARL / MARLlib

One repository is all that is necessary for Multi-agent Reinforcement Learning (MARL)
https://marllib.readthedocs.io
MIT License
873 stars 141 forks source link

Problem with render function #193

Open mrz1999 opened 10 months ago

mrz1999 commented 10 months ago

I have trained the model and it give me as results a folder: exp_results in which there are the checkpoint_000010 etc. folders and also the params.json file. I want to use the trained model for making prediction, I've seen the example with render but when I put the path of the folder with the parameters and the last checkpoint it return me the following error:

Traceback (most recent call last): File "inference.py", line 21, in coma.render(env, model, File "/home/mzampella/Projects/multi_agent/.venv/lib/python3.8/site-packages/marllib/marl/init.py", line 330, in render self.fit(env, model, stop, **running_params) File "/home/mzampella/Projects/multi_agent/.venv/lib/python3.8/site-packages/marllib/marl/init.py", line 313, in fit run_cc(self.config_dict, env_instance, model_class, stop=stop) File "/home/mzampella/Projects/multi_agent/.venv/lib/python3.8/site-packages/marllib/marl/algos/run_cc.py", line 166, in run_cc results = POlICY_REGISTRY[exp_info["algorithm"]](model, exp_info, run_config, env_info, stop_config, File "/home/mzampella/Projects/multi_agent/.venv/lib/python3.8/site-packages/marllib/marl/algos/scripts/coma.py", line 94, in run_coma check_exp = exp["model"]["custom_model_config"]['model_arch_args'] KeyError: 'model'

Can you help me please?

Theohhhu commented 10 months ago

Can you please share the full script you're using, along with the directory structure, including project files and checkpoints?

mrz1999 commented 10 months ago

In the end I was able to find the correct file. But I still have problem with the render function. I just want to take the trained model, apply it to my dataset and call the render function of my environment but when I try to use the render function of this library it starts calling my render also during the training, also if the episode is not concluded. How can I simply obtain the final render of the trained model ?

Aequatio-Space commented 8 months ago

The render function in MARLlib is a mocked version of fit(), which trains just one iteration and starts an evaluation iteration. I passed "lr=0" to mute any training progress for that training iteration. You need to override the render function in your environment to get the final render result.