Create hyperparam combinations with dataclasses
Project description
superparams
a Pythonic approach to Hyperparameter Search. Using built-in dataclasses, as they are flexible, typed, easily-serialisable, and are a dict in the places you need them.
Usage
from dataclasses import dataclass
from hyperparameters import GridSearch, search
@dataclass
class Hyperparams(GridSearch):
epochs :int = 3
batch_size :int = search([16, 32])
learning_rate :int = search([1e-5, 2e-5])
This inherits a bunch of useful attributes, and constructs an iterator.
for h in Hyperparams():
print(h)
# Outputs:
# Hyperparams(epochs=3, batch_size=16, learning_rate=1e-05)
# Hyperparams(epochs=3, batch_size=16, learning_rate=2e-05)
# Hyperparams(epochs=3, batch_size=32, learning_rate=1e-05)
# Hyperparams(epochs=3, batch_size=32, learning_rate=2e-05)
Flexibility
Dataclasses don't require Java-style repetitive constructors. To modify your hyperparameter combination, simply instantiate it as follows.
Hyperparams(epochs=search([1,2,3]))
# Search 3 dimensions, total 12 combinations
# epochs: [1, 2, 3]
# batch_size: [16, 32]
# learning_rate: [1e-05, 2e-05]
Installation
A single file for now. Just copy it over.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superparams-0.0.1.tar.gz.
File metadata
- Download URL: superparams-0.0.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1bfc74dd8c1ce8dedd66f30870cd53a951d9370d127bc1d9f463a4279ce67e2
|
|
| MD5 |
a5b29bde9bef8b35a0ce092a2b7e23ea
|
|
| BLAKE2b-256 |
cf6a94ab5d65087b8b644df10858e377790b712525c056f241d06ee26b0fafbf
|
File details
Details for the file superparams-0.0.1-py3-none-any.whl.
File metadata
- Download URL: superparams-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d1b1d8f201ee4eb35c1ddcd63424de0b25916fdc56190f21a3df27a13525375
|
|
| MD5 |
9f37098e7eef2a980b215ed467276824
|
|
| BLAKE2b-256 |
44807cd4816479b9fe3ef24f1d7d57bf74729c140a9f83477d348945754d075b
|
File details
Details for the file superparams-0.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: superparams-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9e9cf55e353b8aa047837ab98d6294bfa8e11dc6e358e73b4772524808c69fc
|
|
| MD5 |
c45322535bea0b07ba9f4dba8ca84929
|
|
| BLAKE2b-256 |
74f8c0fb49c959600db7f5057c4e285e2030b1e30c6078e2726958744bd34dd2
|