LukeWood / keras-genetic

18 stars 1 forks source link

open ai gym evaluator built in #17

Open LukeWood opened 2 years ago

LukeWood commented 2 years ago

this could be like:

def evaluate_cartpole(individual: keras_genetic.Individual, env): model = individual.load_model() state = env.reset() total_reward = 0

done = False
while not done:
    action_probs = model(np.expand_dims(state, axis=0))
    action = np.argmax(np.squeeze(action_probs))
    state, reward, done, _ = env.step(action)
    total_reward += reward

return total_reward