|
1 | | -# hyperparameter |
2 | | -a library for hyper parameter |
| 1 | +**H**_yper_**P**_arameter_ |
| 2 | +=========================== |
| 3 | + |
| 4 | +A hyper-parameter library for researchers, data scientists and machine learning engineers. |
| 5 | + |
| 6 | +- [**H**_yper_**P**_arameter_](#hyperparameter) |
| 7 | +- [Quick Start](#quick-start) |
| 8 | + - [Object-Style API:](#object-style-api) |
| 9 | + - [Scoped Parameter](#scoped-parameter) |
| 10 | +- [Examples](#examples) |
| 11 | + - [parameter tunning for researchers](#parameter-tunning-for-researchers) |
| 12 | + - [experiment tracing for data scientists](#experiment-tracing-for-data-scientists) |
| 13 | + - [design-pattern for system engineers](#design-pattern-for-system-engineers) |
| 14 | + |
| 15 | +Quick Start |
| 16 | +============ |
| 17 | + |
| 18 | +## Object-Style API: |
| 19 | + |
| 20 | +```python |
| 21 | +from hyperparameter import HyperParameter |
| 22 | + |
| 23 | +params = HyperParameter(a=1, b={'c': 2}) |
| 24 | +params.a == 1 # True |
| 25 | +params.b.c == 2 # True (nested parameter) |
| 26 | +``` |
| 27 | + |
| 28 | +or becomes powerful with `params()`: |
| 29 | + |
| 30 | +```python |
| 31 | +params().a.b.c.getOrElse(3) # 3 (default value) |
| 32 | +params().a.b.c(3) # 3 (shortcut for default value) |
| 33 | + |
| 34 | +params().a.b.c = 4 # set value to param `a.b.c` |
| 35 | +params().a.b.c(3) # 4 (default value is ignored) |
| 36 | +``` |
| 37 | + |
| 38 | +## Scoped Parameter |
| 39 | + |
| 40 | +```python |
| 41 | +from hyperparameter import param_scope |
| 42 | + |
| 43 | +# scoped parameter |
| 44 | +with param_scope(a=1) as hp: |
| 45 | + hp.a == 1 # True |
| 46 | +``` |
| 47 | +or becomes powerful with `nested scope`: |
| 48 | +``` python |
| 49 | +with param_scope(a=1) as hp: |
| 50 | + with param_scope(a=2) as hp: |
| 51 | + hp.a == 2 # True, a=2 for inner scope |
| 52 | + hp.a == 1 # True, a=1 for outer scope |
| 53 | +``` |
| 54 | + |
| 55 | +even more powerful when using `param_scope` in function: |
| 56 | + |
| 57 | +```python |
| 58 | +#change function behavior with scoped parameter: |
| 59 | +def foo(arg): |
| 60 | + # receive parameter using param_scope |
| 61 | + with param_scope() as hp: |
| 62 | + if (hp().param1.getOrElse(1) == 1): |
| 63 | + return 1 |
| 64 | + else: |
| 65 | + return 2 |
| 66 | + ... |
| 67 | + |
| 68 | +# call function with default parameter |
| 69 | +foo() # 1 |
| 70 | + |
| 71 | +# passing parameter using param_scope |
| 72 | +with param_scope(param1=2): |
| 73 | + foo() # 2 |
| 74 | +``` |
| 75 | + |
| 76 | +Examples |
| 77 | +======== |
| 78 | + |
| 79 | +## [parameter tunning for researchers](examples/sparse_lr/README.md) |
| 80 | + |
| 81 | +This example shows how to use hyperparameter in your research projects, and make your experiments reproducible. |
| 82 | + |
| 83 | +## experiment tracing for data scientists |
| 84 | + |
| 85 | +Todo. |
| 86 | + |
| 87 | +## design-pattern for system engineers |
| 88 | + |
| 89 | +Todo. |
0 commit comments