similar problems to this have been posted and answered on this forum but this particular case I didn't find any solution. ( I'm using Keras )
I have images of the shape (150,75,3)
and I reshaped the numpy array to (1,150,75,3)
This is supposed to work but this error comes out:
ValueError: Error when checking input: expected conv2d_input to have 4 dimensions, but got array with shape (1, 1, 1, 150, 75, 3)
EDIT : this is how I process the image :
self.pinballEnvironmrnt = PinballEnv(self.screenDimensions,self.startPosition)
image = pygame.surfarray.array3d(self.pinballEnvironmrnt.screen)
#image = Image.fromarray(image)
#image = image.resize(self.resize)
self.state = numpy.array([image])#.reshape((-1,1200,600,3))
print('the shape of the state ------------------> ',self.state.shape)
output ( error not included in this pic):
and this is the DQN agent :
pool_size = (2, 2)
# MODEL 1
self.model = Sequential()
self.model.add(Conv2D(4, (3, 3),input_shape=(150,75,3),activation='relu'))
# Conv Layer 2
self.model.add(Conv2D(8, (3, 3),activation='relu'))
# Pooling 1
self.model.add(MaxPooling2D(pool_size=pool_size))
self.model.add(Flatten())
self.model.add(Dense(128,activation='relu'))
self.model.add(Dense(64,activation='relu'))
self.model.add(Dense(16,activation='relu'))
self.model.add(Dense(actions,activation='linear'))
print(self.model.summary())