I tried using pickle to save the tained agent
try:
agent1 = pickle.load(open(model_file_path, 'rb'))
except:
print("An exception occurred")
train_agent(True)
if agent1 == None:
train_agent(True)
human = Human()
human.set_sym(env1.o)
agent1.set_verbose(True)
start_session(agent1, human, Environment(), draw=2)
pickle.dump(agent1, open(model_file_path, 'wb'))
return agent1.prediction
But the file that saves the agent becomes very heavy approx 1gb, hence i am not able to resue the agent
HDF5 Format is a grid format that is ideal for storing multi-dimensional arrays of numbers. For example: using Keras/Tensorflow you can very easy save/load model and weights:
# Save the model
model.save('path_to_my_model.h5')
# Recreate the exact same model purely from the file
new_model = keras.models.load_model('path_to_my_model.h5')
# Save weights
model.save_weights('path_to_my_weights.h5')
# Load weights
new_model.load_weights('path_to_my_weights.h5')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.