UserWarning: WARN: Box bound precision lowered by casting to 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)
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
.