在使用Python SDK通过以下代码的内置算法之一(在本例中为图像分类器)启动SageMaker超参数调整作业时:
# [...] Some lines elided for brevity
from sagemaker.tuner import HyperparameterTuner, IntegerParameter, CategoricalParameter, ContinuousParameter
hyperparameter_ranges = {'optimizer': CategoricalParameter(['sgd', 'adam']),
'learning_rate': ContinuousParameter(0.0001, 0.2),
'mini_batch_size': IntegerParameter(2, 30),}
objective_metric_name = 'validation:accuracy'
tuner = HyperparameterTuner(image_classifier,
objective_metric_name,
hyperparameter_ranges,
max_jobs=50,
max_parallel_jobs=3)
tuner.fit(inputs=data_channels, logs=True)
作业失败,在SageMaker Web控制台中检查作业状态时出现此错误:
ClientError: Additional hyperparameters are not allowed (u'sagemaker_estimator_module', u'sagemaker_estimator_class_name' were unexpected) (caused by ValidationError)
Caused by: Additional properties are not allowed (u'sagemaker_estimator_module', u'sagemaker_estimator_class_name' were unexpected)
Failed validating u'additionalProperties' in schema: {u'$schema': u'http://json-schema.org/schema#', u'additionalProperties': False, u'definitions': {u'boolean_0_1': {u'oneOf': [{u'enum': [u'0', u'1'], u'type': u'string'}, {u'enum': [0, 1], u'type': u'number'}]}, u'boolean_true_false_0_1': {u'oneOf': [{u'enum': [u'true', u'false',
我没有在任何地方显式传递sagemaker_estimator_module
或sagemaker_estimator_class_name
属性,因此我不确定为什么返回此错误。
开始进行此调优工作的正确方法是什么?
答案 0 :(得分:1)
我通过this post translated from Japanese找到了答案。
使用Python SDK中的内置算法开始超参数调整作业时,您需要像这样将include_cls_metadata=False
作为关键字参数明确传递给tuner.fit()
:< / p>
tuner.fit(inputs=data_channels, logs=True, include_cls_metadata=False)