Python AWS-Unicode错误导致的算法错误:';ascii';编解码器可以';t编码位置1-2的字符:序号不在范围内(128)

Python AWS-Unicode错误导致的算法错误:';ascii';编解码器可以';t编码位置1-2的字符:序号不在范围内(128),python,unicode,character-encoding,amazon-sagemaker,Python,Unicode,Character Encoding,Amazon Sagemaker,我正在学习在AWS Sagemaker上使用机器学习模型进行训练和转换,AWS Sagemaker使用Python 3.6 我能够成功地训练线性学习者模型,但在转换过程中,我遇到了一个错误: 意外状态异常:转换作业线性学习者-2019-08-30-11-22-02-821的错误:失败。原因:ClientError:有关详细信息,请参阅作业日志 哪些映射到CloudWatch日志中的此错误 算法错误:(由UNICODEENCODEER错误引起) 原因:“ascii”编解码器无法对位置1-2中的字符

我正在学习在AWS Sagemaker上使用机器学习模型进行训练和转换,AWS Sagemaker使用Python 3.6

我能够成功地训练线性学习者模型,但在转换过程中,我遇到了一个错误:

意外状态异常:转换作业线性学习者-2019-08-30-11-22-02-821的错误:失败。原因:ClientError:有关详细信息,请参阅作业日志

哪些映射到CloudWatch日志中的此错误

算法错误:(由UNICODEENCODEER错误引起)
原因:“ascii”编解码器无法对位置1-2中的字符进行编码:序号不在范围内(128)

我使用的代码是这样的
创建和训练模型

为测试数据创建输入和输出S3位置

batch_input ='s3://{}/{}/test/examples'.format(bucket, prefix) # The location of the test dataset   
batch_output = 's3://{}/{}/batch-inference'.format(bucket, prefix) # The location to store the results of the batch transform job

print(batch_input)
print(batch_output)
housing_test=strat_test_set
housing_test_inputs =full_pipeline.transform (housing_test)
housing_test_inputs=np.float32(housing_test_inputs)
housing_test_labels=strat_test_set['median_house_value'].values
housing_test_labels=np.float32(housing_test_labels)
转换测试数据

batch_input ='s3://{}/{}/test/examples'.format(bucket, prefix) # The location of the test dataset   
batch_output = 's3://{}/{}/batch-inference'.format(bucket, prefix) # The location to store the results of the batch transform job

print(batch_input)
print(batch_output)
housing_test=strat_test_set
housing_test_inputs =full_pipeline.transform (housing_test)
housing_test_inputs=np.float32(housing_test_inputs)
housing_test_labels=strat_test_set['median_house_value'].values
housing_test_labels=np.float32(housing_test_labels)
检查要素数量的一致性

print(housing_test_labels.shape)
print(housing_test_inputs.shape)
print(housing_labels.shape)
print(housing_inputs.shape)
从上面返回的值是

(4128,)
(4128, 18)
(16512,)
(16512, 18)
测试数据上传到S3

buf = io.BytesIO()
smac.write_numpy_to_dense_tensor(buf, housing_test_inputs, housing_test_labels)
buf.seek(0)
key = 'examples'
boto3.resource('s3').Bucket(bucket).Object(os.path.join(prefix, 'test', key)).upload_fileobj(buf)
s3_test_data = 's3://{}/{}/test/{}'.format(bucket, prefix, key)
print('uploaded test data location: {}'.format(s3_test_data))
预测值

transformer = linear.transformer(instance_count=1, instance_type='ml.m4.xlarge', output_path=batch_output)

transformer.transform(data=batch_input, data_type='S3Prefix', content_type='text/csv', split_type='Line')

transformer.wait()
我在控制台收到的错误是-

意外状态异常回溯(最后一次最近调用) 在() 3.transformer.transform(数据=批处理输入,数据类型='S3Prefix',内容类型='text/csv',拆分类型='Line') 4. ---->5.等等

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/transformer.py正在等待(self) 227“占位符文档字符串” 228自我.\u确保\u最后一次\u转换\u作业() -->229 self.latest\u transform\u job.wait() 230 231定义确保最后一次转换作业(自我):

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/transformer.py正在等待(self) 344 345 def等待(自我): -->346 self.sagemaker会话。等待转换作业(self.job\u名称) 347 348@staticmethod

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/session.py正在等待转换作业(self、job、poll) 1050 """ 1051 desc=_wait_until(lambda:_transform_job_status(self.sagemaker_client,job),poll) ->1052自我检查作业状态(作业,说明,“TransformJobStatus”) 1053返回说明 1054

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/session.py in\u check\u job\u status(self、job、desc、status\u key\u name) 1077 ), 1078允许的_状态=[“已完成”、“已停止”], ->1079实际状态=状态, 1080 ) 1081

意外状态异常:Transform job linear-learner-2019-08-30-11-22-02-821的错误:失败。原因:ClientError:有关详细信息,请参阅作业日志


是否有人可以建议此错误的根本原因以及如何解决此问题?

请编辑您的问题,以包括从您的终端运行的
locale
locale charmap
命令的输出。@snakecharmerb我正在使用AWS Sagemaker online环境。如何执行locale和locale charmap命令?