Package: params-proto
2022/07/04:Moveneo_prototo top-level, move olderparams_prototov1namespace.Implement nested update viaglobal
prefix.
No relative update via**kwargs, yetFixto_valuebug in Flag2021/06/16: Proto now supports using environment variables as
default.2021/06/13: 5 month into my postdoc at MIT, addsweep.save("sweep.jsonl")to dump the sweep into ajsonlfile
for large scale experiments on AWS.2019/12/09: Just finished my DeepMind Internship. Nowparams-protocontain a new proto implementation, and a
complementary hyperparameter search library! Seeneo_protoandneo_hyper.2019/06/11: Now supportstab-completionat the command line!2018/11/08: Now supports both python3.52as well as3.6!
:bangbang::star:What is “Experiment Parameter Hell”?“Experiemnt Parameter Hell” occurs when you have more than twenty
parameters for your ML project that are all defined as string/function
parameters withclickorargparse. Sometimes these parameters
are defined in a launch script and passes through five layers of
function calls during an experiment.Your Python IDEs work very hard on static code-block analysis to intelligently
make you more productive, and the “parameter hell” breaks all of that.Step 1: Declarative Pattern to the Rescue!For this reason, you want to avoid using dictionaries or opaqueargparsedefinitions as much as possible. Instead, you want to write
those declaratively, so that your IDE can actually help you navigate
through those layers of function calls. The hyper-parameter library,params_protomakes this easy, by integrating python namespaces (a
bare python class) withargparse, so that on the python side you get
auto-completion, and from the command line you can pass in changes.InstallationFirst let’s installparams-protoand its supporting modulewaterbearpipinstallparams-protowaterbearThen to declare your hyperparameters, you can write the following in ayour_project/soft_ac/config.pyfile:importsysfromparams_proto.protoimportParamsProto,Flag,Proto,PrefixProto# this is the first config schemaclassArgs(PrefixProto):"""Soft-actor Critic Implementation with SOTA Performance
    """debug=Trueif"pydevd"insys.moduleselseFalsecuda=Flag("cuda tend to be slower.")seed=42env_name="FetchReach-v1"n_workers=1ifdebugelse12v_lr=1e-3pi_lr=1e-3n_initial_rollouts=0ifdebugelse100n_test_rollouts=15demo_length=20clip_inputs=Flag()normalize_inputs=Flag()# this is the second schemaclassLfGR(PrefixProto):# reportinguse_lfgr=Truestart=0ifArgs.debugelse10store_interval=10visualization_interval=10Step 2: Sweeping Hyper-parameters :fire:Then you an sweep the hyperparameter via the following declarative
pattern:fromrlimportmain,Argsfromparams_proto.hyperimportSweepif__name__=='__main__':fromlp_analysisimportinstrwithSweep(Args,LfGR)assweep:# override the defaultArgs.pi_lr=3e-3Args.clip_inputs=True# this was a flag# override the second config objectLfGR.visualization_interval=40# product between the zipped and the seedwithsweep.product:# similar to python zip, unpacks a list of values.withsweep.zip:Args.env_name=['FetchReach-v1','FetchPush-v1','FetchPickAndPlace-v1','FetchSlide-v1']Args.n_epochs=[4,12,12,20]Args.n_workers=[5,150,200,500]# the seed is sweeped at lastArgs.seed=[100,200,300,400,500,600]# You can save the sweep into a `jsonl` filesweep.save('sweep.jsonl')fori,depsinsweep.items():thunk=instr(main,deps,_job_postfix=f"{Args.env_name}")print(deps)and it should print out a list of dictionaries that looks like:{Args.pi_lr:3e-3,Args.clip_inputs:True,LfGR.visualization_interval:40,Args.env_name:"FetchReach-v1",...Args.seed:100}{Args.pi_lr:3e-3,Args.clip_inputs:True,LfGR.visualization_interval:40,Args.env_name:"FetchReach-v1",...Args.seed:200}{Args.pi_lr:3e-3,Args.clip_inputs:True,LfGR.visualization_interval:40,Args.env_name:"FetchReach-v1",...Args.seed:300}...## Where Can I find Documentation?Look at the specification file athttps://github.com/episodeyang/params_proto/blob/master/test_params_proto/*.py, which is part of the
integrated test. These scripts contains the most comprehensive set of
usage patters!!The new version has aneo_prefix. We will deprecate the older
(non-neo) version in a few month.Writing documentation as uhm…, man page?Params-Protoexposes your argument namespace’s doc string as the
usage note. For users of your code-block, there is no better help than the one
that comes with the script itself!Withparams-proto, your help is only one-haway :)AndYour code-block becomes the documentation.Tab-completion for your script!params_protousesargparsetogether withargcomplete, which
enables command line autocomplete on tabs! To enable runpipinstallparams-proto# then:activate-global-python-argcompleteFor details, see`argcomplete’s
documentation <https://github.com/kislyuk/argcomplete#installation>`__.Why Use Params_Proto Instead of Click or Argparse?Because this declarative, singleton pattern allows you to:Place all of the arguments under a namespace that can be statically
checked.so that your IDE can:Find usage of each argumentjump fromanywherein your code-block base to the declaration of that
argumentrefactor your argument namein the entire code-block baseautomaticallyParams_protois the declarative way to write command line arguments,
and is the way to go for ML projects.How to override when calling from pythonIt is very easy to over-ride the parameters when you call your function:
have most of your training code-blockdirectlyreference the parser
namespace (your configuration namespace really), and just monkey patch
the attribute.params-protoworks very well with the clound ML launch tooljaynes. Take a look at the
automagic awesomeness ofjaynes:)To Develop And Contributegitclonehttps://github.com/episodeyang/params_proto.gitcdparams_protomakedevTo test, run the following under both python3.52and3.6.maketestThismake devcommand should build the wheel and install it in your
current python environment. Take a look at thehttps://github.com/episodeyang/params_proto/blob/master/Makefilefor details.To publish, first update the version number, then do:makepublish