This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax enable | |
set nu | |
highlight BadWhitespace ctermbg=red guibg=red | |
au BufNewFile,BufRead *.py | |
\ set fileformat=unix | | |
\ set encoding=utf-8 | | |
\ match BadWhitespace /\s\+$/ | |
set tabstop=4 | |
set shiftwidth=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.datasets import mnist | |
(X_train, y_train), (X_test, y_test) = mnist.load_data() | |
#Scale the data to between 0 and 1 | |
X_train = X_train/ 255 | |
X_test = X_test/ 255 | |
#Flatten arrays from (28x28) to (784x1) | |
X_train = X_train.reshape(60000,784) | |
X_test = X_test.reshape(10000,784) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the usual imports for a vanilla nueral net | |
import keras | |
from keras.models import Sequential | |
from keras.layers import Dense | |
model = Sequential() | |
model.add(Dense(16, input_shape=input_shape, activation='relu',name = 'input_layer')) | |
model.add(Dense(16, activation='relu', name="hidden_layer")) | |
model.add(Dense(10,activation='softmax',name="output_layer")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#imports we know we'll need | |
import skopt | |
# !pip install scikit-optimize if necessary | |
from skopt import gbrt_minimize, gp_minimize | |
from skopt.utils import use_named_args | |
from skopt.space import Real, Categorical, Integer | |
import keras | |
from keras.models import Sequential | |
from keras.layers import Dense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dim_learning_rate = Real(low=1e-4, high=1e-2, prior='log-uniform', | |
name='learning_rate') | |
dim_num_dense_layers = Integer(low=1, high=5, name='num_dense_layers') | |
dim_num_input_nodes = Integer(low=1, high=512, name='num_input_nodes') | |
dim_num_dense_nodes = Integer(low=1, high=28, name='num_dense_nodes') | |
dim_activation = Categorical(categories=['relu', 'sigmoid'], | |
name='activation') | |
dim_batch_size = Integer(low=1, high=128, name='batch_size') | |
dim_adam_decay = Real(low=1e-6,high=1e-2,name="adam_decay") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.optimizers import Adam | |
def create_model(learning_rate, num_dense_layers,num_input_nodes, | |
num_dense_nodes, activation, adam_decay): | |
#start the model making process and create our first layer | |
model = Sequential() | |
model.add(Dense(num_input_nodes, input_shape= input_shape, activation=activation | |
)) | |
#create a loop making a new dense layer for the amount passed to this model. | |
#naming the layers helps avoid tensorflow error deep in the stack trace. | |
for i in range(num_dense_layers): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@use_named_args(dimensions=dimensions) | |
def fitness(learning_rate, num_dense_layers, num_input_nodes, | |
num_dense_nodes,activation, batch_size,adam_decay): | |
model = create_model(learning_rate=learning_rate, | |
num_dense_layers=num_dense_layers, | |
num_input_nodes=num_input_nodes, | |
num_dense_nodes=num_dense_nodes, | |
activation=activation, | |
adam_decay=adam_decay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K.clear_session() | |
tensorflow.reset_default_graph() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gp_result = gp_minimize(func=fitness, | |
dimensions=dimensions, | |
n_calls=12, | |
noise= 0.01, | |
n_jobs=-1, | |
kappa = 5, | |
x0=default_parameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gbrt_result = gbrt_minimize(func=fitness, | |
dimensions=dimensions, | |
n_calls=12, | |
n_jobs=-1, | |
x0=default_parameters) |
OlderNewer