Gabe Hollombe
Gabe Hollombe

Reputation: 8067

Amazon SageMaker hyperparameter tuning error for built-in algorithm using the Python SDK

When using the Python SDK to start a SageMaker hyperparameter tuning job using one of the built-in algorithms (in this case, the Image Classifier) with the following code:

# [...] 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)

The job fails and I get this error when checking on the job status in the SageMaker web console:

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',

I'm not explicitly passing the sagemaker_estimator_module or sagemaker_estimator_class_name properties anywhere, so I'm not sure why it's returning this error.

What's the right way to start this tuning job?

Upvotes: 3

Views: 997

Answers (1)

Gabe Hollombe
Gabe Hollombe

Reputation: 8067

I found the answer via this post translated from Japanese.

When starting hyperparameter tuning jobs using the built-in algorithms in the Python SDK, you need to explicitly pass include_cls_metadata=False as a keyword argument to tuner.fit() like this:

tuner.fit(inputs=data_channels, logs=True, include_cls_metadata=False)

Upvotes: 2

Related Questions