Python >> Python Tutorial >  >> Python

UserWarning:WARN:Boxgebundene Genauigkeit durch Casting auf float32 verringert

Casten Sie einfach den dtype der Werte Sie passieren Box bis float32 :

self.action_space = spaces.Box(np.float32(low), np.float32(high))

Zum Beispiel sind auch alle diese Beispiele gültig:

self.action_space = spaces.Box(np.float32(3), np.float32(4.0))

self.action_space = spaces.Box(np.float32(np.array([3.0,3.5])), np.float32(np.array([4.0,4.5])))

self.action_space = spaces.Box(np.array([3.0,3.5],dtype=np.float32), np.array([4.0,4.5],dtype=np.float32))

Übrigens:Du kannst die Box zwar auch explizit casten -dtype sich auf np.float32 wie @Robert Wilkerson vorschlägt, besteht keine Notwendigkeit dafür:Es löst das Problem nicht und hat keine Wirkung als dtype von Box ist bereits standardmäßig np.float32 .


Geben Sie explizit dtype an als float32 im Anruf so...

self.action_space = spaces.Box(low, high, dtype=np.float32)

Wenn das nicht funktioniert, stellen Sie den Logger-Pegel im Fitnessstudio niedriger ein ...

import gym
gym.logger.set_level(40)