TypeError: Cannot interpret ‘4’ as a data type
问题:
在写代码时,self.observations = np.zeros((self.max_size, state_dim),其中self.max_size和state_dim分别是两个参数,结果报错:TypeError: Cannot interpret '4' as a data type
分析:
numpy.zeros()参数为:numpy.zeros(shape, dtype=float, order='C', *, like=None)

关于shape的介绍:
shapeint or tuple of ints
Shape of the new array, e.g., (2, 3) or 2.
解决:
因此对于多维的应该加括号:self.observations = np.zeros((self.max_size, state_dim))
473

被折叠的 条评论
为什么被折叠?



