Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed Sep 17, 2019
1 parent 549d368 commit 54ed883
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 1,189 deletions.
83 changes: 0 additions & 83 deletions examples/deep_learning/cnn_cifar10.py
Original file line number Diff line number Diff line change
@@ -1,83 +0,0 @@
<table>
<tbody>
<tr align="center" valign="center">
<td>
<strong>Optimization Techniques</strong>
<img src="images/blue.jpg"/>
</td>
<td>
<strong>Supported Packages</strong>
<img src="images/blue.jpg"/>
</td>
<td>
<strong>Advanced Features</strong>
<img src="images/blue.jpg"/>
</td>
</tr>
<tr/>
<tr valign="top">
<td>
<a><b>Local Search:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#hill-climbing">Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#stochastic-hill-climbing">Stochastic Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#tabu-search">Tabu Search</a></li>
</ul>
<a><b>Random Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-search">Random Search</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-restart-hill-climbing">Random Restart Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-annealing">Random Annealing</a></li>
</ul>
<a><b>Markov Chain Monte Carlo:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#simulated-annealing">Simulated Annealing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#stochastic-tunneling">Stochastic Tunneling</li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#parallel-tempering">Parallel Tempering</a></li>
</ul>
<a><b>Population Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#particle-swarm-optimization">Particle Swarm Optimizer</li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#evolution-strategy">Evolution Strategy</a></li>
</ul>
<a><b>Sequential Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#bayesian-optimization">Bayesian Optimization</a></li>
</ul>
</td>
<td>
<a><b>Machine Learning:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#scikit-learn">Scikit-learn</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#xgboost">XGBoost</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#lightgbm">LightGBM</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#catboost">CatBoost</a></li>
</ul>
<a><b>Deep Learning:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#keras">Keras</a></li>
</ul>
<a><b>Distribution:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#multiprocessing">Multiprocessing</a></li>
</ul>
</td>
<td>
<a><b>Position Initialization:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#scatter-initialization">Scatter-Initialization</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#warm-start">Warm-start</a></li>
</ul>
<a><b>Resource Allocation:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#memory">Memory</a></li>
<li>Proxy Datasets (coming soon)</li>
</ul>
<a><b>Weight Initialization:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#transfer-learning">Transfer-learning</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
83 changes: 0 additions & 83 deletions examples/deep_learning/cnn_mnist.py
Original file line number Diff line number Diff line change
@@ -1,83 +0,0 @@
<table>
<tbody>
<tr align="center" valign="center">
<td>
<strong>Optimization Techniques</strong>
<img src="images/blue.jpg"/>
</td>
<td>
<strong>Supported Packages</strong>
<img src="images/blue.jpg"/>
</td>
<td>
<strong>Advanced Features</strong>
<img src="images/blue.jpg"/>
</td>
</tr>
<tr/>
<tr valign="top">
<td>
<a><b>Local Search:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#hill-climbing">Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#stochastic-hill-climbing">Stochastic Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#tabu-search">Tabu Search</a></li>
</ul>
<a><b>Random Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-search">Random Search</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-restart-hill-climbing">Random Restart Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-annealing">Random Annealing</a></li>
</ul>
<a><b>Markov Chain Monte Carlo:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#simulated-annealing">Simulated Annealing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#stochastic-tunneling">Stochastic Tunneling</li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#parallel-tempering">Parallel Tempering</a></li>
</ul>
<a><b>Population Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#particle-swarm-optimization">Particle Swarm Optimizer</li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#evolution-strategy">Evolution Strategy</a></li>
</ul>
<a><b>Sequential Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#bayesian-optimization">Bayesian Optimization</a></li>
</ul>
</td>
<td>
<a><b>Machine Learning:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#scikit-learn">Scikit-learn</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#xgboost">XGBoost</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#lightgbm">LightGBM</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#catboost">CatBoost</a></li>
</ul>
<a><b>Deep Learning:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#keras">Keras</a></li>
</ul>
<a><b>Distribution:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#multiprocessing">Multiprocessing</a></li>
</ul>
</td>
<td>
<a><b>Position Initialization:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#scatter-initialization">Scatter-Initialization</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#warm-start">Warm-start</a></li>
</ul>
<a><b>Resource Allocation:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#memory">Memory</a></li>
<li>Proxy Datasets (coming soon)</li>
</ul>
<a><b>Weight Initialization:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#transfer-learning">Transfer-learning</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
132 changes: 49 additions & 83 deletions examples/deep_learning/mlp_classification.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,49 @@
<table>
<tbody>
<tr align="center" valign="center">
<td>
<strong>Optimization Techniques</strong>
<img src="images/blue.jpg"/>
</td>
<td>
<strong>Supported Packages</strong>
<img src="images/blue.jpg"/>
</td>
<td>
<strong>Advanced Features</strong>
<img src="images/blue.jpg"/>
</td>
</tr>
<tr/>
<tr valign="top">
<td>
<a><b>Local Search:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#hill-climbing">Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#stochastic-hill-climbing">Stochastic Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#tabu-search">Tabu Search</a></li>
</ul>
<a><b>Random Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-search">Random Search</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-restart-hill-climbing">Random Restart Hill Climbing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#random-annealing">Random Annealing</a></li>
</ul>
<a><b>Markov Chain Monte Carlo:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#simulated-annealing">Simulated Annealing</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#stochastic-tunneling">Stochastic Tunneling</li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#parallel-tempering">Parallel Tempering</a></li>
</ul>
<a><b>Population Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#particle-swarm-optimization">Particle Swarm Optimizer</li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#evolution-strategy">Evolution Strategy</a></li>
</ul>
<a><b>Sequential Methods:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/optimizers#bayesian-optimization">Bayesian Optimization</a></li>
</ul>
</td>
<td>
<a><b>Machine Learning:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#scikit-learn">Scikit-learn</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#xgboost">XGBoost</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#lightgbm">LightGBM</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#catboost">CatBoost</a></li>
</ul>
<a><b>Deep Learning:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#keras">Keras</a></li>
</ul>
<a><b>Distribution:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive/model#multiprocessing">Multiprocessing</a></li>
</ul>
</td>
<td>
<a><b>Position Initialization:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#scatter-initialization">Scatter-Initialization</a></li>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#warm-start">Warm-start</a></li>
</ul>
<a><b>Resource Allocation:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#memory">Memory</a></li>
<li>Proxy Datasets (coming soon)</li>
</ul>
<a><b>Weight Initialization:</b></a>
<ul>
<li><a href="https://github.com/SimonBlanke/Hyperactive/tree/master/hyperactive#transfer-learning">Transfer-learning</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import RMSprop
from keras.utils import to_categorical

from sklearn.model_selection import train_test_split
from sklearn.datasets import load_breast_cancer
from hyperactive import Hyperactive

data = load_breast_cancer()
X, y = data.data, data.target
y = to_categorical(y)


def model(para, X, y):
model = Sequential()
model.add(Dense(para["layer0"], activation="relu"))
model.add(Dropout(para["dropout0"]))
model.add(Dense(para["layer1"], activation="relu"))
model.add(Dropout(para["dropout1"]))
model.add(Dense(2, activation="softmax"))

model.compile(
loss="categorical_crossentropy", optimizer=RMSprop(), metrics=["accuracy"]
)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
model.fit(X_train, y_train, batch_size=128, epochs=10, verbose=1)
score = model.evaluate(X_test, y_test, verbose=0)

return score, model


# this defines the model and hyperparameter search space
search_config = {
model: {
"layer0": range(10, 301, 5),
"layer1": range(10, 301, 5),
"dropout0": np.arange(0.1, 1, 0.1),
"dropout1": np.arange(0.1, 1, 0.1),
}
}


opt = Hyperactive(search_config, n_iter=100, n_jobs=1)

# search best hyperparameter for given data
opt.fit(X, y)

0 comments on commit 54ed883

Please sign in to comment.