This release is a pre-release and may not be stable for production use.
Keras Toolkit
A collection of functions to help you easily train and run Tensorflow Keras
Get the complete API reference here.
Quickstart
Install the library:
pip install keras-toolkit
You can now use it:
import keras_toolkit as kt
# kt reduces the number of lines from ~100 to ~3
strategy = kt.accelerator.auto_select(verbose=True)
decoder = kt.image.build_decoder(with_labels=True, target_size=(300, 300))
dtrain = kt.image.build_dataset(paths, labels, bsize=BATCH_SIZE, decode_fn=decoder)
with strategy.scope():
model = tf.keras.Sequential([...])
model.compile(...)
model.fit(...)
Usage
To automatically select an accelerator (e.g. TPU, GPU, CPU) and run on that accelerator:
import keras_toolkit as kt
strategy = kt.accelerator.auto_select(verbose=True)
with strategy.scope():
# your keras code here
model = tf.keras.Sequential([...])
To restrict the GPU memory usage of TensorFlow (e.g. to 2GB):
import keras_toolkit as kt
kt.accelerator.limit_gpu_memory(2*1024)
To build an image dataset from a list of paths and a list of labels (associated with the paths):
import keras_toolkit as kt
dtrain = kt.image.build_dataset(paths, labels)
# => <PrefetchDataset shapes: ((None, 256, 256, 3), (None,)), types: (tf.float32, tf.int32)>
# Fit your keras model on that new tf.data.Dataset:
model.fit(dtrain, ...)
If you only have a list of image paths, it will create tf.data.Dataset without labels:
dtrain = kt.image.build_dataset(paths)
# => <PrefetchDataset shapes: (None, 256, 256, 3), types: tf.float32>
You can also customize the dataset (e.g. batch size, custom image loader, custom augmentation, etc.):
# This is just the default
img_decoder = kt.image.build_decoder(target_size=(512, 512))
augmenter = kt.image.build_augmenter()
dset = build_dataset(
paths, labels,
decode_fn=img_decoder,
bsize=64,
cache="./cache_dir/",
augment=augmenter,
shuffle=False,
random_state=42
)
Acknowledgement
- The
kt.accelerator.auto_select_acceleratorwas inspired by Martin Gorner's Kaggle notebook. - The
kt.accelerator.limit_gpu_memorywas taken from Chris Deotte's Kaggle notebook.
Metadata
Release files for keras-toolkit 0.1.0rc6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keras-toolkit-0.1.0rc6.tar.gz | 5.4 kB | Without provenance | Details for keras-toolkit-0.1.0rc6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keras_toolkit-0.1.0rc6-py3-none-any.whl | Python 3 | none | any | Details for keras_toolkit-0.1.0rc6-py3-none-any.whl |
Total release size: 11.3 kB
Release files / keras-toolkit-0.1.0rc6.tar.gz
| Download URL | keras-toolkit-0.1.0rc6.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6d4572f9a43ca670015558d3a331203eab6c6aab61b2c6ff9dd4ed8665b5f61
|
|
BLAKE2b-256 checksum How to use checksums |
db08a4a145607a900d6c0a964e798aacb55505b63196cda157d02aa75617bcd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / keras_toolkit-0.1.0rc6-py3-none-any.whl
| Download URL | keras_toolkit-0.1.0rc6-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89ff93f8b37409f1471c94e23b0a60f6bdff47fea09aeb4f33e009b20c71a7f6
|
|
BLAKE2b-256 checksum How to use checksums |
07ecf49bb540685a9795ed05154d26079a1495653870c2992eab06cb391240d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for keras-toolkit 0.1.0rc6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.