I'm using one of Keras's deep q-learning agents: DQNAgent. When I pass my environment into DQNAgent.fit, I receive the following error:
**3 dqn.fit(env, nb_steps=50000, visualize=False, verbose=1)**
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training_utils_v1.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
655 ': expected ' + names[i] + ' to have ' + 656 str(len(shape)) + ' dimensions, but got array ' **657 'with shape ' + str(data_shape))** 658 if not check_batch_axis: 659 data_shape = data_shape[1:]
ValueError: Error when checking input: expected dense_18_input to have 2 dimensions, but got array with shape (1, 1, 65)
My environment's states and spaces are defined as follows:
self.state = np.zeros(65, dtype=int)
self.action_space = spaces.Tuple((spaces.Discrete(64), spaces.Discrete(64)))
self.observation_space = spaces.Box(low=0, high=16, shape=(65,), dtype=np.int)
and I'm using the following model:
states = env.observation_space.shape
actions = 64**2
def build_model(states, actions):
model = Sequential()
model.add(Dense(100, activation='relu', input_shape=states))
model.add(Dense(200, activation='relu'))
model.add(Dense(actions, activation='linear'))
return model
My environment's state vector is of shape (65,), but the fit method beefs it up to (1, 1, 65)--causing a shape mismatch. To be clear, self.state is returned as the observation from the environment. Does anyone know why this is happening?