【问题标题】:Sagemaker Blazingtext .content_type = 'application/json' AttributeError: can't set attributeSagemaker Blazingtext .content_type = 'application/json' AttributeError: 无法设置属性
【发布时间】:2021-03-04 20:03:55
【问题描述】:

我正在尝试使用 BlazingText 模型在 Sagemaker 上运行监督模型。这是我用于运行估计器、超参数调整、部署到容器和模型调用的代码。我看到“属性错误:无法设置属性”。

bt = sagemaker.estimator.Estimator(container,
role,
instance_count=1,
instance_type='ml.m5.large',
input_mode='File',
output_path=s3_output_location)

bt.set_hyperparameters(mode='supervised')

Code for model tuning
bt.fit(inputs=s3_channels)

Code to deploy to container
customer_entity = bt.deploy(initial_instance_count=1, instance_type='ml.t2.medium')

Invoking the model
customer_entity.content_type = 'application/json'
response = customer_entity.predict(json.dumps(payload))

Error

AttributeError Traceback (most recent call last)
in
----> 1 customer_entity.content_type = 'application/json'
2 response = customer_entity.predict(json.dumps(payload))
3 #response = customer_entity.predict(payload)

AttributeError: can't set attribute

【问题讨论】:

    标签: python nlp artificial-intelligence amazon-sagemaker


    【解决方案1】:

    来自 SageMaker 团队。您正在使用 SageMaker v2。使用 v2,您无需直接设置 content_type,而是在 Serializer 实例中设置内容类型。您可以在 Predictor 的构造函数中执行此操作,也可以在之后设置 predictor.serializer。请注意,您可以使用已经创建的序列化程序类,该类允许您指定 content_type 或实现一个自定义类以处理 content_type。

    【讨论】:

      猜你喜欢
      • 2021-04-04
      • 2015-02-08
      • 1970-01-01
      • 2014-08-09
      • 2019-05-01
      • 2017-07-17
      • 2014-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多