An extension pack for keras-tuner for providing additional optimizers.
Project description
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
[!NOTE] Please note that this is a very early draft of
keras-tuner-extensionpack
. This version may contain incomplete features, bugs, or major changes.
Contributing
Contributions to keras-tuner-extensionpack
are welcome!
License
[!WARNING] This project was partially generated with extended support by GitHub Copilot and may not be completely verified. Please use with caution and feel free to report any issues you encounter. Thank you!
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 Distribution
File details
Details for the file keras_tuner_extensionpack-0.1.0.tar.gz
.
File metadata
- Download URL: keras_tuner_extensionpack-0.1.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71c05ae5f200f7c2a022c384a88410b1094a1f0f0d6a0c4c00395806519d6f82 |
|
MD5 | 7200708ee54237ab7e92407721aecda5 |
|
BLAKE2b-256 | a877ec3d6679d97a2b8cda28bdac9b3f402bc6d820673453607c3388b275dba4 |
File details
Details for the file keras_tuner_extensionpack-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: keras_tuner_extensionpack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98de8aec6e475001c45ec016832431e9dba709d08d283127232a6a0af8b93c19 |
|
MD5 | 03a5c9c3bed40887c1005b75688d445b |
|
BLAKE2b-256 | a2ec3fc3ed4473d265a72a0afbec77fb19103301f8970dce17c491a2d3735be0 |