简体   繁体   English

安装 keras model 时,文件“mtrand.pyx”中出现 Numpy 错误

[英]Numpy error in file “mtrand.pyx” while fitting a keras model

I am using:我在用:

  • keras-rl2: 1.0.4 keras-rl2:1.0.4
  • tensorflow: 2.4.1 tensorflow:2.4.1
  • numpy: 1.19.5 numpy:1.19.5
  • gym 0.18.0健身房 0.18.0

For the training of a DQN model for a reinforcement learning project.用于强化学习项目的 DQN model 训练。

My action space contains 60 dicrete values:我的动作空间包含 60 个离散值:

self.action_space = Discrete(60)

and I am getting this error after x steps:我在 x 步骤后收到此错误:

1901/10000 [====>.........................] - ETA: 1:02 - reward: 6.1348Traceback (most recent call last):
  File "D:/GitHub/networth-simulation/rebalancing_simple_discrete.py", line 203, in <module>
    dqn.fit(env, nb_steps=5000, visualize=False, verbose=1)
  File "D:\GitHub\networth-simulation\venv\lib\site-packages\rl\core.py", line 169, in fit
    action = self.forward(observation)
  File "D:\GitHub\networth-simulation\venv\lib\site-packages\rl\agents\dqn.py", line 227, in forward
    action = self.policy.select_action(q_values=q_values)
  File "D:\GitHub\networth-simulation\venv\lib\site-packages\rl\policy.py", line 227, in select_action
    action = np.random.choice(range(nb_actions), p=probs)
  File "mtrand.pyx", line 928, in numpy.random.mtrand.RandomState.choice
ValueError: probabilities contain NaN

When I use a lower number of discrete actions (<10) it doesn't happen every time.当我使用较少数量的离散动作(<10)时,它不会每次都发生。

I found that fix but I don't understand how to apply it.我找到了该修复程序,但我不明白如何应用它。 I can't find any file "numpy/random/mtrand/mtrand.pyx"我找不到任何文件“numpy/random/mtrand/mtrand.pyx”

Has anyone found a way to fix that error?有没有人找到解决该错误的方法?

This error apparently pops up when the values of environment class attributes become too high (positively or negatively).当环境 class 属性的值变得过高(正或负)时,显然会弹出此错误。

I solved the problem with limitations in my step() method.我解决了我的 step() 方法的限制问题。

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

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