question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dueling network with atari

See original GitHub issue

I’m using the dueling dqn with atari environnment. 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) I think it’s because the neural network is trained with a batch.

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

4reactions
NathanBWaterscommented, Apr 14, 2019

You can remove the unnecessary dimension(s) by using your own processor.

class CustomProcessor(Processor):
    '''
    acts as a coupling mechanism between the agent and the environment
    '''

    def process_state_batch(self, batch):
        '''
        Given a state batch, I want to remove the second dimension, because it's
        useless and prevents me from feeding the tensor into my CNN
        '''
        return numpy.squeeze(batch, axis=1)

2reactions
DevanshBesaincommented, Apr 25, 2018

The problem is that the emulator returns observation of shape (1,1,224,224,3) which when passed to your input (shape ?,224,224,3) causes a value error due to dimension mismatch try changing input shape to

input_shape=(1,height,width,channel)

now your input must expect a shape of (?,1,224,224,3) note that the extra dimension we add here represents the window of sequence observed for storing in the memory which we set using “window_length=1” parameter in SequentialMemory

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maximum Entropy Dueling Network Architecture in Atari Domain
In this paper, we propose an improved architecture based upon Dueling Networks, in this architecture, there are two separate estimators, ...
Read more >
Dueling Network Architectures for Deep Reinforcement Learning
Task Dataset Model Metric Name Metric Value Global Rank Atari Games Atari 2600 Alien Duel hs Score 1486.5 # 32 Atari Games Atari 2600 Alien...
Read more >
Dueling Network Architectures for Deep Reinforcement Learning
See, attend and drive: Value and advantage saliency maps (red-tinted overlay) on the Atari game Enduro, for a trained dueling architecture. The value...
Read more >
A implementation of Dueling DQN agent for Atari Breakout.
Based on the Natural DQN for Atari Breakout implemented by lukeluocn, we modified the model according to paper Dueling Network Architectures for Deep ......
Read more >
demo of Dueling Network with Playing Atari 'Breakout'
This video demonstrates Playing Atari 26600 'Breakout' with the algorithm of Dueling Network.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found