Package: autohparams
AutoHparamsAutomatically create a hparams of hyper-parameters from global variables!View Demo·Report BugAbout The ProjectHave you ever run some machine learning training run for hours, just to realize days later that you forgot to save some hyper-parameters? So you need to pray for your memory to be good, or re-run everything?AutoHparams is a tool that dumps every variable in the global scope of your code to a dictionary that you can save using your favorite tool. This helps to avoid 80% of the missed hyper-parameters situations.Getting StartedUsing AutoHparams is a one-liner.Install AutoHparams with pip :pipinstallautohparamsImport it in your code, by adding this line :fromautohparamsimportget_auto_hparamsTo get a hparams dictionnary, just do:hparams=get_auto_hparams(globals())Advanced tipBy default,get_auto_hparamsignores variables whose name starts with an underscore_. This is convenient to filter the variables you want to include in the hparams.For example:lr=0.001# we want to report learning ratebs=64# we want to report batch size_gpu=0# we don't want to report the gpu usedhparams=get_auto_hparams(globals())UsageYou can now use it in any framework you want, for example:Tensorboardimporttensorflowastffromtensorboard.plugins.hparamsimportapiashpwithtf.summary.create_file_writer('logs/hparam_tuning').as_default():hp.hparams(hparams)MLflowimportmlflowwithmlflow.start_run():mlflow.log_params(hparams)Weights & Biases (wandb)importwandbwandb.init(hparams=hparams)Comet.mlfromcomet_mlimportExperimentexperiment=Experiment()experiment.log_parameters(hparams)Neptune.aiimportneptune.newasneptunerun=neptune.init()run['parameters']=hparamsPytorch Lightningimportpytorch_lightningaspltrainer=pl.Trainer(logger=...)trainer.logger.log_hyperparams(hparams)Guild AIimportguildguild.run(hparams=hparams)Polyaxonimportpolyaxon_sdkapi_client=polyaxon_sdk.ApiClient()api_client.create_hyper_params(run_uuid='uuid-of-your-run',body=hparams)ClearMLfromclearmlimportTasktask=Task.init()task.set_parameters(hparams)Kubeflowfromkubeflow.metadataimportmetadatastore=metadata.Store()store.log_metadata(hparams)Even faster importIf you like python wizardry, you can also import and use autohparams as a function:importautohparamsconfig=autohparams(globals())One cannot do easier!(back to top)ContributingContributions are welcome!Roadmap/todoNon-Code contribution :TaskImportanceDifficultyContributor on itDescriptionAdding documentation4/51/5NOBODYWrite basic tutorials with real-life scenarios, write a wiki for other contributors to better understand the functioning of the library.For every todo, just click on the link to find the discussion where I describe how I would do it.See thediscussionsfor a full list of proposed features (and known issues).(back to top)How to contributeContributing is an awesome way to learn, inspire, and help others. Any contributions you make aregreatly appreciated, even if it's just about styling and best practices.If you have a suggestion that would make this project better, please fork the repo and create a pull request.Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/YourAmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestAuthorsThis library was created byNicolas MICAUX.