-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observation's Shape #628
Comments
You are probably doing something like this.
The problem is that changing the configuration is "lazy", it only has an effect when the environment is reset (e.g. you can't change the number of lanes in the middle of a simulation). So while you've change the configuration at step 2., it's not effective immediately and the observation shape will remain (5, 5) until the env is reset at 4., but by then the model will have been initialised at 3. expecting a (5, 5) shape. The solution is to do something like
Or even better, pass the desired config to the first initialisation:
And the same applies to testing the trained model, the environment has to be properly initialised/reset before. |
I have done what you first suggest, do First I loaded the model and initialized the environment, then I runned the aforementioned cycle:
But on the predict step, due to the The data file of the models contains:
For LidarObservation:
Why does it expect the kinematics's shape?? |
You're right, it looks like training worked as intended and the observation shapes expected by the policies are correct. |
Output:
|
I have trained a model using LidarObservation as following:
By default:
print(env.observation_space) outputs: Box(-inf, inf, (5, 5), float32)
. But, only by doingenv.reset()
it becomesObservation Shape after Reset: (16, 2)
.I was trying to test the model by loading it
model = Algorithm.load(model_path)
and running a few episodes but whenobs, info = env.reset()
is done, the shape changes to(16,2)
. Therefore, when doing model.predict() it gives me the following error:Error: Unexpected observation shape (16, 2) for Box environment, please use (5, 5) or (n_env, 5, 5) for the observation shape.
The same happens for TimeToCollision which is
Box(-inf, inf, (5, 5), float32)
and becomes(3, 3, horizon)
Does anyone know what's happening?
The text was updated successfully, but these errors were encountered: