我正在使用TensorFlow +脚本模式在SageMaker中进行培训,目前正在为我的数据使用“文件”输入模式。
有没有人想出如何使用“管道”数据格式结合脚本模式培训来传输数据?
您可以从训练脚本导入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
你可以在这里找到关于sagemaker_tensorflow的文档https://github.com/aws/sagemaker-tensorflow-extensions#using-the-pipemodedataset