Comments (2)
@sakalouski I can't seem to replicate your error, but I suspect that has to do with the operating system and Python version you're running on, since it seems like the error is occurring when BBopt tries to lock the data file (which is a necessary step--it won't work if you comment out self._load_data()
). It's also possible that there's something different about the code you're actually running and the version of the code you posted here that I ran. This is the code I ran:
import keras
from keras.optimizers import Nadam
from keras.layers import Input, Dense, Dropout
from keras.callbacks import EarlyStopping, ReduceLROnPlateau
from keras.metrics import mse
from sklearn import datasets
import pandas as pd
from tqdm import tqdm
from bbopt import BlackBoxOptimizer
bb = BlackBoxOptimizer(__file__)
iris = datasets.load_iris()
X = iris.data
Y = iris.target
train_split = int(.6*len(X))
X_train, X_val = X[:train_split], X[train_split:]
Y_train, Y_val = Y[:train_split], Y[train_split:]
def run_trial():
"""Run one trial of hyperparameter optimization."""
# Start BBopt:
bb.run()
input_shape = 4
h_n_num = bb.randint('num_neur',5,1000)
act = bb.choice('activ_func',['selu','relu','elu'])
num_lay = bb.randint('num_hidden_layers',0,10)
dout = bb.uniform("dropout", 0, 1)
lr = bb.uniform("init_learn_rate", 1e-5, 0.1)
bsize = bb.choice('batch_size',[8,16,32,64,128])
# Create model:
a = Input(shape=(input_shape,))
b = Dense(h_n_num,activation=act)(a)
b = Dropout(dout)(b)
for l in range(num_lay):
b = Dense(h_n_num,activation=act)(b)
b = Dropout(dout)(b)
output = Dense(1,activation='linear',name='out')(b)
model = keras.models.Model(inputs=a, outputs=output)
opt = Nadam(lr)
model.compile(optimizer = opt, loss=mse)
# Train model:
history = model.fit(x=X_train[:-70], y=Y_train[:-70],batch_size=bsize,epochs=1,
validation_data=(X_train[-70:],Y_train[-70:]),
verbose=0,
validation_split = 0.4,
callbacks=[EarlyStopping(patience=30),
ReduceLROnPlateau(monitor='val_loss', factor=0.5, patience=25,verbose=0)],
shuffle=False)
train_loss = history.history["loss"][-1]
val_loss = history.history["val_loss"][-1]
bb.remember({
"train_loss": train_loss,
"val_loss": val_loss,
})
bb.minimize(val_loss)
num_trials = 5
result = []
for i in tqdm(range(num_trials)):
run_trial()
result.append(bb.get_current_run())
if len(result)>1:
[i['memo'].update(i['values']) for i in result]
temp = [i['memo'] for i in result]
pd.DataFrame(temp).to_csv('./patch_weekly_5000_trials.csv')
Do you get an error when you run this code?
from bbopt.
@sakalouski Also, if you could try updating your bbopt to 0.4.2 (pip install -U bbopt
) and let me know what the error message you get then is, that would be greatly appreciated.
from bbopt.
Related Issues (16)
- Not able to run the optimizer more than 10 times for Keras implementation HOT 3
- run_backend with Mixture option HOT 8
- Add a framework for dealing with converting old bbopt data to new bbopt data
- I wish i'd seen this... HOT 3
- Add pySOT backend
- Add meta backend HOT 1
- Compatibility with Colab? HOT 4
- [FEATURE]: Run Id should be available in a process HOT 1
- [BUG]: `numpy.random.mtrand.RandomState` object has no attribute `integers` -> switch to `np.random.Generator` HOT 1
- Prevent regenerating the model with each run HOT 1
- Add bbopt endpoint which runs many iterations
- TypeError: Cannot cast array data from dtype('<U4') to dtype('int64') according to the rule 'safe' HOT 4
- Support all scikit-optimize visualization methods HOT 1
- ValueError: 16 is not in list HOT 1
- bbopt seems to be stuck on old version of networkx HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bbopt.