SageMaker脚本模式+管道模式

时间:2019-02-11 20:10:28

标签: python tensorflow streaming amazon-sagemaker

我正在使用TensorFlow +脚本模式在SageMaker中进行培训,目前正在使用“文件”输入模式来存储数据。

有人知道如何结合脚本模式培训使用“管道”数据格式流数据吗?

1 个答案:

答案 0 :(得分:1)

您可以按照以下步骤从训练脚本中导入sagemaker_tensorflow

from sagemaker_tensorflow import PipeModeDataset
from tensorflow.contrib.data import map_and_batch

channel = 'my-pipe-channel-name'

ds = PipeModeDataset(channel)
ds = ds.repeat(EPOCHS)
ds = ds.prefetch(PREFETCH_SIZE)
ds = ds.apply(map_and_batch(parse, batch_size=BATCH_SIZE,
                            num_parallel_batches=NUM_PARALLEL_BATCHES))

您可以在此处找到完整的示例:https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/tensorflow_pipemode_example/pipemode.py

您可以在https://github.com/aws/sagemaker-tensorflow-extensions#using-the-pipemodedataset

上找到有关sagemaker_tensorflow的文档。