成功解决TypeError: only size-1 arrays can be converted to Python scalars

问题描述:

base_action = [ 2.         -1.65909091  2.         -2.          2.          0.22669992
  2.         -2.         -1.62084658  2.         -0.40106834 -2.
 -0.19870362 -1.6288685  -2.          0.02443762 -2.         -1.7053572
  0.83902649 -1.48000453  2.         -1.44656077 -2.          2.
 -1.47518171 -2.          0.44459582 -0.51717101  2.          2.        ]

如上数据的维度为(30,),若使用int(base_action),出现报错如下: TypeError: only size-1 arrays can be converted to Python scalars


解决方案:

将int(base_action)修改为(base_action).astype(np.int)即可

猜你喜欢

转载自blog.csdn.net/weixin_43283397/article/details/109640494