[英]How can i save a trained reinforcement learning agent to avoid training it each time?
我尝试使用泡菜来保存受污染的代理
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
但是保存代理的文件变得非常重,大约 1GB,因此我无法恢复代理
HDF5 格式是一种网格格式,非常适合存储多维数字数组。 例如:使用 Keras/Tensorflow,您可以非常轻松地保存/加载模型和权重:
# 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')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.