Loading a saved model

How should I load the model which is saved while training of cartpole game. so that i can just play the game (testing) without further training
I’ve tried this code:
lodded_model = Agent(4,2)
lodded_model.load(“cartpole_model/weights_350.hdf5”)

for e in range(30):
observation = env.reset()
observation = observation.reshape((1,state_size))

for t in range(500):
    env.render()
    action = lodded_model.act(observation)
    new_observation, reward, done, info = env.step(action)
    
    new_observation = new_observation.reshape((1,state_size))
    observation = new_observation 
   
    if done:
        print("Episode {}/{} with score {}".format(e,30,t))
        break

env.close()
print(“All episodes done”)`

But this gives, random behaviour and low score, whereas if i run this action = agent.act(observation) it performs well. why new model is not able to adapt all those things as that of agent model

Hey Mohit,

Try using the command lodded_model.load_weights(path). That should work.