Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if tuning hyperparameters match with the model's arguments in the tuning mode #233

Closed
WenjieDu opened this issue Nov 12, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request new feature Proposing to add a new feature
Milestone

Comments

@WenjieDu
Copy link
Owner

1. Feature description

Check and list mismatched hyperparameters in the error logging file while in the tuning mode.

2. Motivation

While tuning hyperparameters, if there are typos in the searching-space config file, we need to list mismatched arguments, to help users easily identify them.

PyPOTS/pypots/cli/tuning.py

Lines 123 to 147 in 939ad55

def run(self):
"""Execute the given command."""
if os.getenv("enable_tuning", False):
# fetch the next set of hyperparameters from NNI tuner
tuner_params = nni.get_next_parameter()
# get the specified NN class
model_class = NN_MODELS[self._model]
# pop out the learning rate
lr = tuner_params.pop("lr")
# if tuning a GAN model, we need two optimizers
if "G_optimizer" in model_class.__init__.__annotations__.keys():
# optimizer for the generator
tuner_params["G_optimizer"] = Adam(lr=lr)
# optimizer for the discriminator
tuner_params["D_optimizer"] = Adam(lr=lr)
else:
tuner_params["optimizer"] = Adam(lr=lr)
# init an instance with the given hyperparameters for the model class
model = model_class(**tuner_params)
# train the model and report to NNI
model.fit(train_set=self._train_set, val_set=self._val_set)
else:
logger.error("Argument `enable_tuning` is not set. Aborting...")

3. Your contribution

Will make a PR to add this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new feature Proposing to add a new feature
Projects
None yet
Development

No branches or pull requests

1 participant