IntelLabs / coach

Reinforcement Learning Coach by Intel AI Lab enables easy experimentation with state of the art Reinforcement Learning algorithms
https://intellabs.github.io/coach/
Apache License 2.0
2.32k stars 460 forks source link

Defining observation space dimensions #318

Closed mattiasmar closed 5 years ago

mattiasmar commented 5 years ago

An openai gym.env defines self.observation_space to

 self.observation_space = spaces.Box(0, np.iinfo(np.int32).max,
                                            shape=(34,),
                                            dtype=float)

yet when using coach the below error is generated: ValueError: Cannot feed value of shape (1, 34) for Tensor 'main_level/agent/main/online/network_0/observation/observation:0', which has shape '(?, 0)'

The state returned by the said gym.env is a numpy float array of length 34.

yunzhe-tao commented 5 years ago

Hi, I met the same issue. How did you solve this? Thanks

mattiasmar commented 5 years ago

This is how I defined it:

self.observation_space = spaces.Box(0, np.iinfo(np.int32).max,
                                            shape=(self.observation_space_dim,),
                                            dtype=float)

This code belongs to the init method of your environment.

yunzhe-tao commented 5 years ago

You just replaced 34 with self.observation_space_dim, right? Then why does it solve the issue?

mattiasmar commented 5 years ago

Unfortunately I don't remember what went wrong for me at the time. I have a weak memory that my observation_space_dim variable was not properly initialized. The error was not related to Coach per se and therefore I closed the issue myself.