DongChen06 / MARL_CAVs

MARL for Autonomous Vehicles
253 stars 47 forks source link

Problem running mappo, obs_state is a 5*5 mat, but the actor model's imput is set as 25 #36

Closed xuyangthu66 closed 7 months ago

xuyangthu66 commented 8 months ago

File "D:\毕设\code2\MARL_CAVs\MARL\run_mappo.py", line 254, in train(args) File "D:\毕设\code2\MARL_CAVs\MARL\run_mappo.py", line 136, in train mappo.interact() File "D:\毕设\code2\MARL_CAVs\MARL\MAPPO.py", line 111, in interact action = self.exploration_action(self.env_state, self.n_agents) File "D:\毕设\code2\MARL_CAVs\MARL\MAPPO.py", line 219, in exploration_action softmax_actions = self._softmax_action(state, n_agents) File "D:\毕设\code2\MARL_CAVs\MARL\MAPPO.py", line 209, in _softmax_action softmax_action_var = th.exp(self.actor(state_var[:, agent_id, :])) File "D:\毕设\code2\MARL_CAVs\MARL\single_agent\Model_common.py", line 19, in call out = nn.functional.relu(self.fc1(state)) File "F:\python\anaconda\envs\marl_cav\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "F:\python\anaconda\envs\marl_cav\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, **kwargs) File "F:\python\anaconda\envs\marl_cav\lib\site-packages\torch\nn\modules\linear.py", line 114, in forward return F.linear(input, self.weight, self.bias) RuntimeError: mat1 and mat2 shapes cannot be multiplied (5x5 and 25x128)

Dear writer: I have got this problem, could you teach me how to solve it ? Maybe I can reshape the tensor, but I'm afraid it may cause another problems. Thank you !

xuyangthu66 commented 8 months ago

I check the ' state_dim ' got by the code 'state_dim = env.n_s' , and it returns 25. So maybe it should be 5 ?

DongChen06 commented 8 months ago

Hi, i think it may be due to mismatch of libs, could you try these versions: https://github.com/DongChen06/MARL_CAVs/issues/18, also the issue may come from Windows. The codes were only tested on Ubuntu. You can flat the states into nx25 instead of 5x5.

Chooovy commented 7 months ago

can we have some discussion because I am writing this project too,my wechat is MarkusFits

xuyangthu66 commented 7 months ago

Yes, I have solved this problem. It is because I didn't use the matched highway-env version with your code, and some functions in the abstract.py are changed.

Thanks a lot.

Dong Chen @.***> 于2024年3月22日周五 21:18写道:

Hi, i think it may be due to mismatch of libs, could you try these versions: #18 https://github.com/DongChen06/MARL_CAVs/issues/18

— Reply to this email directly, view it on GitHub https://github.com/DongChen06/MARL_CAVs/issues/36#issuecomment-2015083836, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3URYNVSH3RPD63EQS67SA3YZQVRNAVCNFSM6AAAAABFCS6XDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVGA4DGOBTGY . You are receiving this because you authored the thread.Message ID: @.***>