hyperstate
hyperstate copied to clipboard
Is there any help message supported?
For example, I wrote a complex dataclass with many members. I don't really remember the name of each member. How can I know the correct way to set a member if I don't remember the full name?
I can see some help message in argparse_dataclass like this. Do we support similar functions?
Yes, if you run e.g. the example script with --help
it will show usage help:
⋊> ~/s/hyperstate on main ◦ poetry run python examples/basic_config/main.py --help 06:53:36
usage: main.py [-h] [--config CONFIG] [--hps-info [HPS_INFO]] [-v] [hyperparams [hyperparams ...]]
positional arguments:
hyperparams Hyperparameter values in the form of 'hyper.param=value'.
optional arguments:
-h, --help show this help message and exit
--config CONFIG Optional path to ron config file.
--hps-info [HPS_INFO]
Print information about hyperparameters.
-v, --verbose Print verbose output.
You can pass the --hps-info
option to print out all the different members:
⋊> ~/s/hyperstate on main ◦ poetry run python examples/basic_config/main.py --hps-info 06:54:13
optimizer: OptimizerConfig
lr: float = 0.0001 # Learning rate.
batch_size: int = 512 # Batch size.
optimizer: str = 'adam'
net: NetConfig
hidden_size: int = 128 # Number of activations in the hidden layer.
num_layers: int = 2 # Number of layers.
norm: 'batchnorm'|'layernorm'|None
steps: int = 10 # Number of steps to run.
You can also pass a search term to --hps-info
to do a fuzzy search (doesn't work optimally in all cases yet):
⋊> ~/s/hyperstate on main ◦ poetry run python examples/basic_config/main.py --hps-info nlayer 06:55:30
net.num_layers: int = 2 # Number of layers.
When you pass in a parameter that doesn't exist, hyperstate will try to find similarly named members:
⋊> ~/s/hyperstate on main ◦ poetry run python examples/basic_config/main.py optim='sgd' 06:56:08
error: Unknown field 'optim' for class 'Config
Most similar fields:
optimizer: OptimizerConfig # Optimizer configuration.
optimizer.optimizer: str = 'adam'
wow,thank you! I suggest that you put this message in README. It's a very good feature.