qiongwu86 / DDPG-RIS-MADDPG-POWER

13 stars 3 forks source link

python main_train_ris.py RuntimeError: mat1 and mat2 shapes cannot be multiplied (1x60 and 40x512) 维度不对 #1

Open liuyan-design opened 4 months ago

liuyan-design commented 4 months ago

------------- lanes are ------------- up_lanes : [200.875, 202.625, 400.875, 402.625] down_lanes : [197.375, 199.125, 397.375, 399.125] left_lanes : [200.875, 202.625, 400.875, 402.625] right_lanes : [197.375, 199.125, 397.375, 399.125]

Initializing agent 0 Initializing agent 1 Initializing agent 2 Initializing agent 3 Initializing agent 4 Initializing agent 5 Initializing agent 6 Initializing agent 7 Initializing Global critic ... Initializing DDPG Agent

Restoring the model... ... loading checkpoint ... ... loading checkpoint ... ... loading checkpoint ... ... loading checkpoint ... -------------------------------- step: 0 ------------------------------------------- Traceback (most recent call last): File "main_train_ris.py", line 205, in ris_action = model.get_ris_action(state_old_all) File "/root/DDPG-RIS-MADDPG-POWER/load_models.py", line 92, in get_ris_action action = self.agent.choose_action(np.asarray(state_old_all).flatten()) File "/root/DDPG-RIS-MADDPG-POWER/ddpg.py", line 256, in choose_action mu = self.actor.forward(state).to(self.actor.device) File "/root/DDPG-RIS-MADDPG-POWER/ddpg.py", line 132, in forward x = self.fc1(state) File "/root/miniconda3/envs/ddpg/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "/root/miniconda3/envs/ddpg/lib/python3.8/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 (1x60 and 40x512)

Qi1216 commented 4 months ago

因为我在不同的RIS数量下都进行了训练,在model文件下,3-ris_ddpg_model为RIS=36的模型,后缀加16对应RIS=16。ddpg代码里要改成chkpt_dir='model/3-ris_ddpg_model',对应的M也要都改成36,load_models中有M的设置,main_train_ris中也有,你可以自己寻找。有问题可以与我联系。