繁体   English   中英

恢复特定检查点以使用 Sagemaker 和 TensorFlow 进行部署

[英]Restore a specific checkpoint for deploying with Sagemaker and TensorFlow

我正在使用 SageMaker 来训练我意识到的一些自定义 TF 模型。 在训练期间,我自然会多次评估模型,以了解 NN 何时真正开始过度拟合。 训练后,我想恢复效果最好的模型(即呈现最小验证损失)并将其部署在端点上。 但是,如果我使用经典的 Tensorflow.attach() 恢复的模型与存储在 output/model.tar.gz 中的模型相对应,如果我正确理解,它将是与最后一次训练迭代对应的模型(因此它可能会过拟合)。

有没有办法向 SageMaker 指定恢复哪个检查点,而不必提前停止重新训练模型? 即使强制 SM 在 model.tar.gz 中保存呈现最小验证损失的模型,而不是最后一个对我有用,不幸的是我没有找到任何直接的方法来这样做......

谢谢!

您可以使用 checkpoint_path 从以前的检查点恢复模型:

previous_checkpoint_path = 's3://location/of/my/previous/generated/checkpoints'

tf_estimator = TensorFlow('tf-train.py', role='SageMakerRole',
                          checkpoint_path=previous_checkpoint_path
                          training_steps=10000, evaluation_steps=100,
                          train_instance_count=1, train_instance_type='ml.p2.xlarge',
                          framework_version='1.10.0')
tf_estimator.fit('s3://bucket/path/to/training/data')

想要查询更多的信息:

https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/tensorflow/README.rst#restoring-from-checkpoints

https://sagemaker.readthedocs.io/en/latest/sagemaker.tensorflow.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM