baselines icon indicating copy to clipboard operation
baselines copied to clipboard

ShmemVecEnv does not support float64

Open mitar opened this issue 6 years ago • 7 comments

The _NP_TO_CT map does not contain an entry for float64.

_NP_TO_CT = {np.float32: ctypes.c_float,
             np.int32: ctypes.c_int32,
             np.int8: ctypes.c_int8,
             np.uint8: ctypes.c_char,
             np.bool: ctypes.c_bool}

mitar avatar Dec 04 '18 16:12 mitar

good point, thanks! Will fix shortly (or you can submit a PR :) - but in that case please add a test)

pzhokhov avatar Dec 19 '18 23:12 pzhokhov

This is still a problem. Are there any workarounds while we wait for the PR?

JulianoLagana avatar Aug 05 '19 13:08 JulianoLagana

Changing the dict to the following worked for my application:

_NP_TO_CT = {np.float64: ctypes.c_double,
             np.float32: ctypes.c_float,
             np.int32: ctypes.c_int32,
             np.int8: ctypes.c_int8,
             np.uint8: ctypes.c_char,
             np.bool: ctypes.c_bool}

JulianoLagana avatar Aug 05 '19 13:08 JulianoLagana

Seems that on master branch this is still not yet fixed. What is the reason behind this?

xxbidiao avatar Feb 12 '20 18:02 xxbidiao

also curious as to the holdup. many of us can use SubprocVecEnv as a workaround but its much slower

balloch avatar May 02 '20 19:05 balloch

has there been any fix for this?

when my spaces are with float64 I get:

  File "/home/baselines/baselines/common/vec_env/shmem_vec_env.py", line 50, in <dictcomp>
    {k: ctx.Array(_NP_TO_CT[self.obs_dtypes[k].type], int(np.prod(self.obs_shapes[k]))) for k in self.obs_keys}
KeyError: <class 'numpy.float64'>

a-z-e-r-i-l-a avatar Jul 15 '20 08:07 a-z-e-r-i-l-a

Can't you cast your observations to float32?

On Wed, Jul 15, 2020, 1:29 AM Alireza Ranjbar [email protected] wrote:

has there been any fix for this?

when my spaces are with float64 I get:

File "/home/baselines/baselines/common/vec_env/shmem_vec_env.py", line 50, in {k: ctx.Array(_NP_TO_CT[self.obs_dtypes[k].type], int(np.prod(self.obs_shapes[k]))) for k in self.obs_keys} KeyError: <class 'numpy.float64'>

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openai/baselines/issues/749#issuecomment-658626493, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS63NIJ24FBZ276TS5YB73R3VSH7ANCNFSM4GIEKRLA .

andytwigg avatar Jul 15 '20 15:07 andytwigg