I continuously get this error
UserWarning: WARN: Box bound precision lowered by casting to float32
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
when I start my training session. I guess it's coming from this line
self.action_space = spaces.Box(low, high)
The code is running but I want to stop this error from showing up
I am using a cuda pc to run the code.
Just cast the dtype of the values you pass Box to float32:
self.action_space = spaces.Box(np.float32(low), np.float32(high))
For example, also all these examples are valid:
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))
By the way: While you can also explicitly cast the Box-dtype itself to np.float32 as @Robert Wilkerson suggests, there is no need for it: it does not solve the problem, and it has no effect as the dtype of Box already defaults to np.float32.
Explicitly specify the dtype as float32 in the call like so...
self.action_space = spaces.Box(low, high, dtype=np.float32)
If that doesn't work, set the logger level lower in gym like so...
import gym
gym.logger.set_level(40)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With