0

I would like to use my trained RL model for a discrete test prediction.

This is how the model is built:

model = Sequential()
model.add(Dense(60, activation='relu', input_shape=states))
model.add(Dense(60, activation='relu', input_shape=states))
model.add(Dense(60, activation='relu', input_shape=states))
model.add(Dense(actions, activation='linear'))

The action space is a discrete value. The observation space is one simple float value:

self.action_space = Discrete(len(ACTION_MAP))
observation_high = np.finfo(np.float32).max
self.observation_space = Box(low=np.array([-observation_high]), high=np.array([observation_high]))

The test function works well:

scores = dqn.test(env, nb_episodes=1, visualize=False, verbose=1, callbacks=[CustomCallback()])

but when I do that:

print(dqn.model.predict_step([30]))

I get this error:

ValueError: Input 0 of layer dense is incompatible with the layer: : expected min_ndim=2, found ndim=0. Full shape received: ()

Is it the right way to make a prediction? what should be the input data like?

Vincent Roye
  • 2,751
  • 7
  • 33
  • 53

1 Answers1

0

Solution:

model = keras.models.load_model('models/130000/')
pf = model.predict(sample_to_predict)
best_action = np.argmax(pf[0])
Vincent Roye
  • 2,751
  • 7
  • 33
  • 53