Skip to content

Use of boolean hyperparameters: recommended use of type=bool is not okay #4247

@rq-aszasz

Description

@rq-aszasz

What did you find confusing? Please describe.

doc/overview.rst states:

Note that SageMaker doesn't support argparse actions. If you want to use, for example, boolean hyperparameters, you need to specify type as bool in your script and provide an explicit True or False value for this hyperparameter when you create your estimator.

In accordance with Python 3's argparse documentation, the bool() converter will convert any non empty string to a True value:

The bool() function is not recommended as a type converter. All it does is convert empty strings to False and non-empty strings to True. This is usually not what is desired.

If one parses as per your recommended way, regardless of the default

parser.add_argument('street', type=bool, default=...)

it becomes impossible to set an explicit False configuration from the caller.
This is dangerous and misleading.

Describe how documentation can be improved
Do not say this:

If you want to use, for example, boolean hyperparameters, you need to specify type as bool in your script and provide an explicit True or False value for this hyperparameter when you create your estimator.

The False scenario will not work, it will set the parameter to True.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions