繁体   English   中英

为什么在使用 Deep Q 学习时会弹出此错误?

[英]Why does this error pop up while working with Deep Q learning?

我一直在 Windows 10 机器上使用 Deep Q Learning。 我有带有 NVIDA 显卡的 pytorch 0.4.1 版本。

def select_action(self, state):
    probs = F.softmax(self.model(Variable(state, volatile = True))*7)
    action = probs.multinomial()
    return action.data[0,0]

从代码的这一部分,我不断收到此错误:

TypeError: multinomial() missing 1 required positional arguments: "num_samples"

如果需要任何其他信息,将很快提供。

根据文档,您没有指定multinomial函数的num_samples来绘制多项式分布。

torch.multinomial(输入,num_samples,replacement=False,out=None)

返回一个张量,其中每行包含从位于张量input的相应行中的多项式概率分布中采样的num_samples索引。

更改代码如下:

def select_action(self, state):
    probs = F.softmax(self.model(Variable(state, volatile = True))*7)
    action = probs.multinomial(1) # 1 is the number of samples to draw
    return action.data[0,0]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM