keras-tuner-extensionpack
An extension package for KerasTuner for providing more optimizers.
Currently Implemented Algorithms
This package extends KerasTuner with additional optimization algorithms. The currently implemented tuners include:
-
CMA-ES (Covariance Matrix Adaptation Evolution Strategy): An evolutionary algorithm for difficult non-linear non-convex optimization problems in continuous domain.
-
Differential Evolution: A metaheuristic approach that is useful for global optimization of a multidimensional function.
-
Harmony Search: A music-inspired algorithm that is based on the improvisation process of musicians.
-
Simulated Annealing: A probabilistic technique for approximating the global optimum of a given function.
-
Sine Cosine Algorithm: An optimization algorithm inspired by the sine and cosine mathematical functions.
-
Tabu Search: A metaheuristic search method using local or neighborhood search procedures for mathematical optimization.
-
Variable Depth Search: A search algorithm that explores more deeply into chosen paths in the search tree, rather than exploring alternative paths at the current level.
Each of these tuners can be used as via:
from keras_tuner_extensionpack.benchmark.functions import shifted_ackley
from keras_tuner_extensionpack.differential_evolution import DifferentialEvolution
import keras_tuner
class MyTuner(DifferentialEvolution):
def run_trial(self, trial, *args, **kwargs):
# Get the hp from trial.
hp = trial.hyperparameters
# Define "x" as a hyperparameter.
x = hp.Float(
"x",
min_value=-5,
max_value=5,
step=1e-8,
sampling="linear",
)
y = hp.Float(
"y",
min_value=-5,
max_value=5,
step=1e-8,
sampling="linear",
)
return shifted_ackley([x, y])
Algorithms are pre-tested for:
def shifted_ackley(x: np.ndarray, shift: tuple = (1, 0.5)) -> float:
"""Shifted Ackley function.
Args:
x (np.ndarray): Input vector.
shift (np.ndarray): Shift vector.
Returns:
float: Output value.
"""
return ackley(np.array([x[i] - shift[i] for i in range(len(x))]))
def sphere(x: np.ndarray) -> float:
"""Sphere function.
Args:
x (np.ndarray): Input vector.
Returns:
float: Output value.
"""
return np.sum(x**2)
def rosenbrock(x: np.ndarray) -> float:
"""Rosenbrock function.
Args:
x (np.ndarray): Input array of shape with larger than 2,
representing the coordinates.
Returns:
float: Output value.
"""
return np.sum(100.0 * (x[1:] - x[:-1] ** 2.0) ** 2.0 + (1 - x[:-1]) ** 2.0, axis=0)
Install
pip install keras-tuner-extensionpack
or:
pip install git+https://github.com/Anselmoo/keras-tuner-extensionpack
Contributing
Contributions to keras-tuner-extensionpack are welcome!
License
Metadata
Release files for keras-tuner-extensionpack 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| keras_tuner_extensionpack-0.1.0.tar.gz | 27.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keras_tuner_extensionpack-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.7 kB
Release files / keras_tuner_extensionpack-0.1.0.tar.gz
| Download URL | keras_tuner_extensionpack-0.1.0.tar.gz |
|---|---|
| Size | 27.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71c05ae5f200f7c2a022c384a88410b1094a1f0f0d6a0c4c00395806519d6f82
|
|
BLAKE2b-256 checksum How to use checksums |
a877ec3d6679d97a2b8cda28bdac9b3f402bc6d820673453607c3388b275dba4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / keras_tuner_extensionpack-0.1.0-py3-none-any.whl
| Download URL | keras_tuner_extensionpack-0.1.0-py3-none-any.whl |
|---|---|
| Size | 45.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98de8aec6e475001c45ec016832431e9dba709d08d283127232a6a0af8b93c19
|
|
BLAKE2b-256 checksum How to use checksums |
a2ec3fc3ed4473d265a72a0afbec77fb19103301f8970dce17c491a2d3735be0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|