boyu-ai / Hands-on-RL

https://hrl.boyuai.com/
Apache License 2.0
2.16k stars 493 forks source link

第八章 `In [7]`代码块,VAnet() 疑似有误 #54

Open Aegis1863 opened 1 year ago

Aegis1863 commented 1 year ago

Q = V + A - A.mean(1).view(-1, 1) 疑似应为 Q = V + A - A.mean(-1).view(-1, 1) 否则传入单个状态,也就是state时,A的shape为(3),A.mean(1)会报错,因为只有一个维度;而传入批量状态states时,A的shape为(128,3),此时A.mean(1)不会报错;若修改为A.mean(-1),符合原本思路,且不会报错。

具体差别参考下图: image

image

YYan99 commented 1 month ago

报错可能是因为state外面没加中括号[] state = torch.tensor([state], dtype=torch.float).to(self.device)