hardmaru / WorldModelsExperiments

World Models Experiments
603 stars 170 forks source link

ValueError: cannot reshape array of size 27648 into shape (1,64,64,3) #1

Closed sakusss closed 6 years ago

sakusss commented 6 years ago

when I run the 'python model.py render /log/' there is a value error I cannot fix that .I use python 3.6.5

hardmaru commented 6 years ago

Hi @sakusss

When you cloned the repo, does this command work?

“python model.py render log/carracing.cma.16.64.best.json”

(From blog post)

It should work. Let me know if it doesn’t.

tegg89 commented 6 years ago

Hi, I am using Linux and same value error also have happened. Maybe the repo works in Mac OS.

hardmaru commented 6 years ago

Hi @tegg89 @sakusss

I tried it out on an Ubuntu Linux machine (16.04) and it works for me. Below are the sequence of commands I used, and the corresponding text output I see.

Clone repo:

> git clone http://github.com/hardmaru/WorldModelsExperiments
Cloning into 'WorldModelsExperiments'...
remote: Counting objects: 97, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 97 (delta 26), reused 79 (delta 18), pack-reused 0
Unpacking objects: 100% (97/97), done.
Checking connectivity... done.

Go to carracing dir:

> cd WorldModelsExperiments/carracing/

Run command (loading model in log/carracing.cma.16.64.best.json):

> python model.py render log/carracing.cma.16.64.best.json
filename log/carracing.cma.16.64.best.json
2018-06-18 05:00:03.757051: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not c
ompiled to use: AVX2 FMA
model using cpu
input dropout mode = False
output dropout mode = False
recurrent dropout mode = False
model size 867
loading file log/carracing.cma.16.64.best.json
Track generation: 1103..1435 -> 332-tiles track
retry to generate track (normal if there are not many of this messages)
Track generation: 1171..1476 -> 305-tiles track
total reward 883.5526315789326 timesteps 999
terminal reward [883.5526315789326] average steps taken 1000.0

Can you let me know what is the exact command you typed (making sure you are inside the the WorldModelsExperiments/carracing directory before launching the command, and right after cloning the repo), and the exact error you are seeing?

Can you also test whether the command without loading a model also works for you?

Run command with no model (so model parameters are randomly initialized):

> python model.py render
2018-06-18 04:59:17.374032: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not c
ompiled to use: AVX2 FMA
model using cpu
input dropout mode = False
output dropout mode = False
recurrent dropout mode = False
model size 867
Track generation: 1227..1538 -> 311-tiles track
total reward -75.90967741935523 timesteps 372
terminal reward [-75.90967741935523] average steps taken 373.0

Below are the versions of python, gym, numpy, tensorflow, box2d that I'm using:

> pip show python
> python --version
Python 3.5.2 :: Anaconda custom (64-bit)
> pip show gym
Name: gym
Version: 0.9.2
Summary: The OpenAI Gym: A toolkit for developing and comparing your reinforcement learning agents.
Home-page: https://github.com/openai/gym
Author: OpenAI
Author-email: gym@openai.com
License: UNKNOWN
Requires: six, numpy, pyglet, requests
Required-by: ppaquette-gym-doom
> pip show numpy
Name: numpy
Version: 1.13.3
Summary: NumPy: array processing for numbers, strings, records, and objects.
Home-page: http://www.numpy.org
Author: NumPy Developers
Author-email: numpy-discussion@python.org
License: BSD
Requires: 
Required-by: torch, tensorflow, tensorflow-tensorboard, tensorboard, tables, PyWavelets, patsy, pandas, odo, numba, matplotlib, h5py, gym, dynd, datashape, Bottleneck, astropy, doom-py, torchvision
> pip show tensorflow
Name: tensorflow
Version: 1.8.0
Summary: TensorFlow helps the tensors flow
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Requires: protobuf, gast, astor, termcolor, tensorboard, wheel, absl-py, grpcio, six, numpy
Required-by: 
> pip show box2d
Name: Box2D
Version: 2.3.2
Summary: Python Box2D
Home-page: http://pybox2d.googlecode.com/
Author: Ken Lauer
Author-email: sirkne at gmail dot com
License: zlib
tegg89 commented 6 years ago

Thanks for the reply. I just have tested with Mac OS, and same value error has happened. I have cloned the repo and tried the same command inside of carracing directory. When I have tested python env.py, not an error has happened. However after python model.py, same value error has happened.

Below are the versions that I have used: python: 3.5.4 gym: 0.10.5 tensorflow: 1.8.0 numpy: 1.13.3 box2d: 2.3.2

I have only noticed that the gym has a different version, but would that matter?

tegg89 commented 6 years ago

I just have changed the version of gym to 0.9.2 and the model.py have correctly worked! The different package version matters a lot. The issue has been resolved. Thanks!

sakusss commented 6 years ago

Thank you for your reply! @hardmaru I have also changed the version of gym to 0.9.2 ,and it works :).

hardmaru commented 6 years ago

Hi @tegg89 @sakusss

Can you kindly try to use gym 0.9.x? They made a whole bunch of big changes to gym between 9 and 10, and did things like disable the scoring system on their site :-( I pointed this out on the blog post as well.

The doom environment also only works on 0.9.x

I was planning to port everything over to 0.10.5, but I wanted to get this code out sooner rather than later...

Let me know if you have other issues later on.

Cheers