Sagemaker KMeans 内置 - 文件列表 csv 作为输入
Sagemaker KMeans Built-In - List of files csv as input
我想在我的一个应用程序中使用 Sagemaker KMeans 内置算法。我在 S3(原始数据)中有一个很大的 CSV 文件,我将其分成几个部分以便于清理。在我清理之前,我试图用它作为 Kmeans 的输入来执行训练工作但是它不起作用。
我的清单文件:
[
{"prefix": "s3://<BUCKET_NAME>/kmeans_data/KMeans-2019-28-07-13-40-00-001/"},
"file1.csv",
"file2.csv"
]
我遇到的错误:
Failure reason: ClientError: Unable to read data channel 'train'. Requested content-type is 'application/x-recordio-protobuf'. Please verify the data matches the requested content-type. (caused by MXNetError) Caused by: [16:47:31] /opt/brazil-pkg-cache/packages/AIAlgorithmsCppLibs/AIAlgorithmsCppLibs-2.0.1620.0/AL2012/generic-flavor/src/src/aialgs/io/iterator_base.cpp:100: (Input Error) The header of the MXNet RecordIO record at position 0 in the dataset does not start with a valid magic number. Stack trace returned 10 entries: [bt] (0) /opt/amazon/lib/libaialgs.so(+0xb1f0) [0x7fb5674c31f0] [bt] (1) /opt/amazon/lib/libaialgs.so(+0xb54a) [0x7fb5674c354a] [bt] (2) /opt/amazon/lib/libaialgs.so(aialgs::iterator_base::Next()+0x4a6) [0x7fb5674cc436] [bt] (3) /opt/amazon/lib/libmxnet.so(MXDataIterNext+0x21) [0x7fb54ecbcdb1] [bt] (4) /opt/amazon/python2.7/lib/python2.7/lib-dynload/_ctypes.so(ffi_call_unix64+0x4c) [0x7fb567a1e858] [bt] (5) /opt/amazon/python2.7/lib/python2.7/lib-dynload/_ctypes.so(ffi_call+0x15f) [0x7fb567a1d95f
我的问题是:是否可以仅在 GUI 中使用多个 CSV 文件作为 Sagemaker KMeans BuilIn 算法的输入?如果可能的话,我应该如何格式化我的清单?
清单看起来不错,但根据错误消息,您似乎没有为 S3 数据设置正确的数据格式。它期待 protobuf,这是默认格式 :)
您必须明确设置 CSV 数据格式。参见 https://sagemaker.readthedocs.io/en/stable/session.html#sagemaker.session.s3_input。
它应该看起来像这样:
s3_input_train = sagemaker.s3_input(
s3_data='s3://{}/{}/train/manifest_file'.format(bucket, prefix),
s3_data_type='ManifestFile',
content_type='csv')
...
kmeans_estimator = sagemaker.estimator.Estimator(kmeans_image, ...)
kmeans_estimator.set_hyperparameters(...)
s3_data = {'train': s3_input_train}
kmeans_estimator.fit(s3_data)
请注意 SDK 中的 KMeans 估计器仅支持 protobuf,请参阅 https://sagemaker.readthedocs.io/en/stable/kmeans.html
我想在我的一个应用程序中使用 Sagemaker KMeans 内置算法。我在 S3(原始数据)中有一个很大的 CSV 文件,我将其分成几个部分以便于清理。在我清理之前,我试图用它作为 Kmeans 的输入来执行训练工作但是它不起作用。
我的清单文件:
[
{"prefix": "s3://<BUCKET_NAME>/kmeans_data/KMeans-2019-28-07-13-40-00-001/"},
"file1.csv",
"file2.csv"
]
我遇到的错误:
Failure reason: ClientError: Unable to read data channel 'train'. Requested content-type is 'application/x-recordio-protobuf'. Please verify the data matches the requested content-type. (caused by MXNetError) Caused by: [16:47:31] /opt/brazil-pkg-cache/packages/AIAlgorithmsCppLibs/AIAlgorithmsCppLibs-2.0.1620.0/AL2012/generic-flavor/src/src/aialgs/io/iterator_base.cpp:100: (Input Error) The header of the MXNet RecordIO record at position 0 in the dataset does not start with a valid magic number. Stack trace returned 10 entries: [bt] (0) /opt/amazon/lib/libaialgs.so(+0xb1f0) [0x7fb5674c31f0] [bt] (1) /opt/amazon/lib/libaialgs.so(+0xb54a) [0x7fb5674c354a] [bt] (2) /opt/amazon/lib/libaialgs.so(aialgs::iterator_base::Next()+0x4a6) [0x7fb5674cc436] [bt] (3) /opt/amazon/lib/libmxnet.so(MXDataIterNext+0x21) [0x7fb54ecbcdb1] [bt] (4) /opt/amazon/python2.7/lib/python2.7/lib-dynload/_ctypes.so(ffi_call_unix64+0x4c) [0x7fb567a1e858] [bt] (5) /opt/amazon/python2.7/lib/python2.7/lib-dynload/_ctypes.so(ffi_call+0x15f) [0x7fb567a1d95f
我的问题是:是否可以仅在 GUI 中使用多个 CSV 文件作为 Sagemaker KMeans BuilIn 算法的输入?如果可能的话,我应该如何格式化我的清单?
清单看起来不错,但根据错误消息,您似乎没有为 S3 数据设置正确的数据格式。它期待 protobuf,这是默认格式 :)
您必须明确设置 CSV 数据格式。参见 https://sagemaker.readthedocs.io/en/stable/session.html#sagemaker.session.s3_input。
它应该看起来像这样:
s3_input_train = sagemaker.s3_input(
s3_data='s3://{}/{}/train/manifest_file'.format(bucket, prefix),
s3_data_type='ManifestFile',
content_type='csv')
...
kmeans_estimator = sagemaker.estimator.Estimator(kmeans_image, ...)
kmeans_estimator.set_hyperparameters(...)
s3_data = {'train': s3_input_train}
kmeans_estimator.fit(s3_data)
请注意 SDK 中的 KMeans 估计器仅支持 protobuf,请参阅 https://sagemaker.readthedocs.io/en/stable/kmeans.html