Skip to content

Encoding of hyperparamters depends on the source_dir #5126

Open
@abdulfatir

Description

@abdulfatir

What did you find confusing? Please describe.
I find it very counterintuitive that the encoding of the hyperparameters depends on the presence of source_dir behind the scenes. I wasted a lot of time debugging this issue after I moved to a setup with no source_dir. Ideally, this should not happen and, in any case, this should not be a detail that's hidden deep inside.

See:

def set_hyperparameters(self, **kwargs):
"""Sets the hyperparameter dictionary to use for training.
The hyperparameters are made accessible as a dict[str, str] to the
training code on SageMaker. For convenience, this accepts other types
for keys and values, but ``str()`` will be called to convert them before
training.
If a source directory is specified, this method escapes the dict argument as JSON,
and updates the private hyperparameter attribute.
"""
if self.source_dir:
self._hyperparameters.update(EstimatorBase._json_encode_hyperparameters(kwargs))
else:
for k, v in kwargs.items():
self._hyperparameters[k] = v

Describe how documentation can be improved
This behavior should ideally NOT exist. However, if there are strong reasons for this, at least it should be mentioned in the docstring for source_dir and/or hyperparameters.

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions