keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.98k stars 19.46k forks source link

Convolutional networks with 3 channel images #6956

Closed Skarwild closed 7 years ago

Skarwild commented 7 years ago

I'm using the dueling dqn with atari environnment. (https://github.com/matthiasplappert/keras-rl/blob/master/examples/dqn_atari.py ) After creating the neural network, I have an error :

`model = Sequential() model.add(Lambda(lambda a: a / 255.0,input_shape=(minecraft_resolution[0],minecraft_resolution[1],3))) model.add(Permute((3, 1, 2))) model.add(Conv2D(32, (8, 8), strides=(2, 2), activation=activation)) model.add(Conv2D(32, (4, 4), strides=(2, 2), activation=activation)) model.add(Conv2D(32, (3, 3), strides=(2, 2), activation=activation)) model.add(Conv2D(32, (2, 2), strides=(1, 1), activation=activation)) model.add(TimeDistributed(Flatten())) model.add(LSTM(128)) for i in xrange(nb_layers): model.add(Dense(hidden_size, activation=activation)) model.add(Dense(env.action_space.n + 1)) model.add(Lambda(lambda a: K.expand_dims(a[:, 0], axis=-1) + a[:, 1:], output_shape=(env.action_space.n,)))

...

memory = SequentialMemory(limit=10000000, window_length=1) agent = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=10, enable_dueling_network=True, dueling_type='avg', target_model_update=1e-3, policy=policy,processor=processor) agent.compile(optimizer, metrics=['mse']) ...

`

ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape (1, 1, 200, 200, 3)

def process_observation(self, observation): return(imresize(observation,(200,200)).shape) the shape is (200, 200, 3)

So my questions are : 1) How to handle colored images with Keras ? 2) How to use Permute with colored images ?

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.