代码之家  ›  专栏  ›  技术社区  ›  Austin

SageMaker脚本模式服务

  •  1
  • Austin  · 技术社区  · 6 年前

    我使用SageMaker脚本模式训练了tensorflow.keras模型,如下所示:

    import os
    
    import sagemaker
    from sagemaker.tensorflow import TensorFlow
    
    estimator = TensorFlow(entry_point='train.py',
                           source_dir='src',
                           train_instance_type=train_instance_type,
                           train_instance_count=1,
                           hyperparameters=hyperparameters,
                           role=sagemaker.get_execution_role(),
                           framework_version='1.12.0',
                           py_version='py3', 
                           script_mode=True)
    

    但是,当我调用时,如何指定服务代码是什么 estimator.deploy() ? 默认情况下是什么?还有没有办法使用脚本模式修改nginx.conf?

    2 回复  |  直到 6 年前
        2
  •  1
  •   Rui    6 年前

    https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/tensorflow/estimator.py#L393 基于TFS的容器不允许使用自定义脚本。您可以使用SERVICE_input_receiver_fn指定输入数据的处理方式,如下所述: https://www.tensorflow.org/guide/saved_model

    至于修改ngnix.conf,没有支持的方法。根据您想要在配置文件中更改的内容,您可以破解sagemaker python sdk,为这些环境变量传递不同的值: https://github.com/aws/sagemaker-tensorflow-serving-container/blob/3fd736aac4b0d97df5edaea48d37c49a1688ad6e/container/sagemaker/serve.py#L29

    https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/tensorflow/serving.py#L130