Comments (5)
i'd like to use keras-tuner but im unclear on this codebase and there's zero documentation on how to use the callback hooks. custom != complicated, i'll just use optuna for now
from keras-tuner.
@bionicles this is definitely on the roadmap, on the Keras Tuner side as well as making it easier on the Keras side to plug custom training step into compile
/fit
On the Keras Tuner side, for complicated use cases the current best way imo is to override the Tuner
class and replace calls to fit
with calls to your custom training logic (and make sure to report the results to the Oracle
and call the callback hooks as necessary)
from keras-tuner.
@bionicles There will be more documentation ahead of the 1.0 launch (coming soon!). The codebase is still in active development, so some things for advanced use cases are still internal but will be exposed externally soon. For now, here's an example of how to implement a custom training loop that should remain stable:
class MyTuner(kerastuner.engine.Tuner):
def run_trial(self, trial, x, y, val_x, val_y):
model = self.hypermodel.build(trial.hyperparameters)
for epoch in range(10):
self.on_epoch_begin(trial, model, epoch, logs={})
for batch in range(100):
self.on_batch_begin(trial, model, batch, logs={})
outputs = model(x)
loss = myloss(outputs, y)
self.on_batch_end(trial, model, batch, logs={'loss': loss})
val_loss = ...
self.on_epoch_end(trial, model, epochs, logs={'val_loss': val_loss})
def build_model(hp):
num_layers = hp.Int('num_layers', 1, 10)
...
return model
tuner = MyTuner(
oracle=kerastuner.tuners.randomsearch.RandomSearchOracle(
objective='val_loss',
max_trials=30),
hypermodel=build_model)
tuner.search(x, y, val_x, val_y)
from keras-tuner.
I'll update this thread again when we have documentation available for best practices for these use cases
from keras-tuner.
Closing as there is now a pending PR for a tutorial on custom training loops: #136
from keras-tuner.
Related Issues (20)
- UnimplementedError: File system scheme '[local]' not implemented on TPU distribute strategy HOT 2
- conditional_scope might not be correctly exemplified.
- Number of consecutive failures raises TypeError instead of RuntimeError
- Exception calling application: can only concatenate str (not "NoneType") to str HOT 1
- Ensure workflows run with minimal permissions
- Model not built with KerasCore when loading best model HOT 2
- Cannot import name 'base_tuner' from 'keras_tuner.engine' HOT 6
- from keras_tuner.engine import trial fails with Import Error on v1.4.1
- attributeerror: 'sequential' object has no attribute "get_build_config" HOT 3
- How to use keras_tuner to improve 1d-cnn model without Sequential() or model. add HOT 2
- Keras Tuner crashes with Keras 3.0 HOT 2
- Chief process does not resume tuning after restart due to missing `chief.json` file HOT 2
- Problem to my code identify the search space from gridsearch
- Publish a security policy
- tuner.get_best_models() issues warning Detecting that an object or model or tf.train.Checkpoint is being deleted with unrestored values HOT 1
- FileNotFoundError for TPU custom loop training HOT 2
- Unable to find conditions in hyperparameter.py after an abrupt end and restart of keras tuner HOT 2
- get_best_model not working when adding normalization layer
- Stop searching after raising Skip Oversized model error
- Distributed keras tuner fails in case when chief oracle server startup takes more than 5 minutes
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 keras-tuner.