Comments (4)
Hi @lordfiftyfive ,
Thanks for the feedback! Mind if I ask which link you mean by the previous link?
The error you mentioned would definitely result in nothing being written to the dashboard. Can you share code for your study.add_observation ? It seems like objective in add_observation is getting a dtype that it argmin cannot be applied to.
Best,
Lars
from sherpa.
I think I actually saw a link which explained how to run sherpa on google colab on a runtime which was not tensorflow 2.0 so after doing some digging I figured out that this was the correct way to pull up the sherpa dashboard with the latest tensorflow version.
from tensorboard import notebook
notebook.display(port=8880, height=1000)
This is the code for my study.
'
import sherpa.algorithms.bayesian_optimization as bayesian_optimization
parameters = [sherpa.Continuous('lrinit', [0.01, 0.011], 'log')]
#sherpa.Continuous('lrdecay', [1e-2, 1e-7], 'log')]
alg = bayesian_optimization.GPyOpt(max_num_trials=50)#sherpa.algorithms.GPyOpt('GP', num_initial_data_points='infer',initial_data_points=[0.1,0.11,0.12], acquisition_type='MPI',verbosity=True)
study = sherpa.Study(parameters=parameters,
algorithm=alg,
lower_is_better=True,port=8884)
batch_size =19
loss = lambda y, rv_y: rv_y.variational_loss(
y, kl_weight=np.array(batch_size, x.dtype) / x.shape[0])
num_iterations = 4
epochs = 18
'
'
for trial in study:
lr = trial.parameters['lrinit']
model = tf.keras.Sequential([
tf.keras.Input(shape=(1,14), dtype=x.dtype),
tf.keras.layers.LSTM(25,activation = 'relu',kernel_initializer='ones', dtype = x.dtype, use_bias=False),
#tf.keras.layers.InputLayer(input_shape=(10),dtype=x.dtype),#put a 1 before the 9 later
tf.keras.layers.Dense(50,kernel_initializer='ones', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(75,kernel_initializer='ones', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(100,kernel_initializer='ones', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(125,kernel_initializer='ones', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(150,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(175,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(200,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(225,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(250,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(225,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(200,kernel_initializer='ones',use_bias=False),
#goal is to eventually replace the first dense layer with an LSTM layer
#tf.keras.layers.LSTM
#tf.keras.layers.TimeDistributed(Dense(vocabulary)))
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(150,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(125,kernel_initializer='ones', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(100,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(75,kernel_initializer='ones', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(50,kernel_initializer='ones',use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(25, kernel_initializer='ones',use_bias=False,),
tfp.layers.VariationalGaussianProcess(
num_inducing_points=num_inducing_points,
kernel_provider=RBFKernelFn(dtype=x.dtype),
inducing_index_points_initializer=tf.compat.v1.constant_initializer(
np.linspace(0,x_range, num=1125,#num_inducing_points,
dtype=x.dtype)[..., np.newaxis]),
unconstrained_observation_noise_variance_initializer=(tf.initializers.constant(100.0)
),
event_shape=[num_distributions_over_Functions],jitter=1e-06
)
#in unconstrained thing replace astype with
])
optimizer = tf.keras.optimizers.Adam(learning_rate=lr)#
model.compile(optimizer=optimizer, loss=loss)
for i in range(epochs):
model.fit(x, y,epochs=epochs, verbose=True,validation_split=0.2)
loss= model.evaluate(x[189::],y[189::])
loss = np.abs(loss)
study.add_observation(trial=trial,iteration=i,objective=loss,context={'loss':loss})
study.finalize(trial=trial)
'
from sherpa.
Hmmm....does model.evaluate(x[189::],y[189::])
return a float? It must be related to the type of loss. Sherpa expects a float for the objective value.
Regarding the dashboard link. I hadn't used
from tensorboard import notebook
notebook.display(port=8880, height=1000)
before. Thanks for sharing. I normally just put localhost:<port>
in the browser to get to the dashboard when running locally (which should correspond to the link given by Sherpa.
from sherpa.
Thanks! That did the trick.
from sherpa.
Related Issues (20)
- Show dashboard after run complete? HOT 1
- pandas >= 1.10 KeyError
- Parallel Sherpa MongoDB access issues HOT 2
- Old version of slickgrid causing dashboard column limit?
- Considering pruned trial information when sampling
- Resume optimization
- ValueError: `f0` passed has more than 1 dimension.
- Sherpa study can not find keras module
- Bayesian optimization with Random Forest HOT 1
- random_seed cannot actually be set when creating a new study HOT 1
- Can't pickle local object 'Flask.init..' HOT 3
- use development install instead of path export?
- trivial Baysian Optimization raises TypeError
- Incompatability with Pandas > 1.5.0
- Possible typo on guide website: HOT 1
- Using shlex to split runner_command HOT 1
- Only install enum34 for old versions of Python HOT 4
- Sherpa Dashboard Links Invalid HOT 1
- Error when using bayesian optimization HOT 5
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 sherpa.