Giter Site home page Giter Site logo

Problem with Dashboard about sherpa HOT 4 CLOSED

sherpa-ai avatar sherpa-ai commented on May 23, 2024
Problem with Dashboard

from sherpa.

Comments (4)

LarsHH avatar LarsHH commented on May 23, 2024

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.

lordfiftyfive avatar lordfiftyfive commented on May 23, 2024

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.

LarsHH avatar LarsHH commented on May 23, 2024

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.

lordfiftyfive avatar lordfiftyfive commented on May 23, 2024

Thanks! That did the trick.

from sherpa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.