i´m new to reinforcement learning, and was trying to use LSTM for reinforcement learning for a space invaders agent. I tried to use the network found in this paper but I kept having trouble:
-If i use conv2D the dimensions with the LSTM dont fit and i get this error:
ValueError: Input 0 is incompatible with layer conv_lst_m2d_1: expected ndim=5, found ndim=4
This is the code:
self.model = Sequential()
self.model.add(Conv2D(32,kernel_size=8,strides=4,activation='relu',input_shape=(None,84,84,1)))
self.model.add(Conv2D(64,kernel_size=4,strides=2,activation='relu'))
self.model.add(Conv2D(64,kernel_size=3, strides=1,activation='relu'))
self.model.add(ConvLSTM2D(512, kernel_size=(3,3), padding='same', return_sequences=False))
self.model.add(Dense(4, activation='relu'))
self.model.compile(loss='mse', optimizer=Adam(lr=0.0001))
self.model.summary()
-And if I use Conv3D that outputs a 5D tensor I cant use one image as an input:
ValueError: Error when checking input: expected conv3d_1_input to have 5 dimensions, but got array with shape (1, 84, 84, 1)
Code:
self.model.add(Conv3D(32,kernel_size=8,strides=4,activation='relu',input_shape=(None,84,84,1)))
self.model.add(Conv3D(64,kernel_size=4,strides=2,activation='relu'))
self.model.add(Conv3D(64,kernel_size=3, strides=1,activation='relu'))
self.model.add(ConvLSTM2D(512, kernel_size=(3,3), padding='same', return_sequences=False))
self.model.add(Dense(4, activation='relu'))
self.model.compile(loss='mse', optimizer=Adam(lr=0.0001))
self.model.summary()
(edit)
Network summary(of the second network):
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv3d_1 (Conv3D) (None, None, 20, 20, 32) 16416
_________________________________________________________________
conv3d_2 (Conv3D) (None, None, 9, 9, 64) 131136
_________________________________________________________________
conv3d_3 (Conv3D) (None, None, 7, 7, 64) 110656
_________________________________________________________________
conv_lst_m2d_1 (ConvLSTM2D) (None, 7, 7, 512) 10618880
_________________________________________________________________
dense_1 (Dense) (None, 7, 7, 4) 2052
=================================================================
And data input shape is: (84, 84, 1)
ConvLSTM2Dlayer, therefore your initial choice of layers seems to work. Can you print the network summary and include in the question as well as an input sample/shape? - nickthefreak