Author: Awais Farooq

  • Simple MNIST convnet

    Setup Prepare the data Build the model Model: “sequential” ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓ ┃ Layer (type) ┃ Output Shape ┃ Param # ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩ │ conv2d (Conv2D) │ (None, 26, 26, 32) │ 320 │ ├─────────────────────────────────┼───────────────────────────┼────────────┤ │ max_pooling2d (MaxPooling2D) │ (None, 13, 13, 32) │ 0 │ ├─────────────────────────────────┼───────────────────────────┼────────────┤ │ conv2d_1 (Conv2D) │ (None, 11, 11, 64) │ 18,496…

  • Image classification from scratch

    Introduction This example shows how to do image classification from scratch, starting from JPEG image files on disk, without leveraging pre-trained weights or a pre-made Keras Application model. We demonstrate the workflow on the Kaggle Cats vs Dogs binary classification dataset. We use the image_dataset_from_directory utility to generate the datasets, and we use Keras image preprocessing layers…

  • KerasNLP Tokenizers

    Tokenizers convert raw string input into integer input suitable for a Keras Embedding layer. They can also convert back from predicted integer sequences to raw string output. All tokenizers subclass keras_nlp.tokenizers.Tokenizer, which in turn subclasses keras.layers.Layer. Tokenizers should generally be applied inside a tf.data.Dataset.map for training, and can be included inside a keras.Model for inference.

  • KerasNLP Models

    KerasNLP contains end-to-end implementations of popular model architectures. These models can be created in two ways: Below, we list all presets available in the library. For more detailed usage, browse the docstring for a particular class. For an in depth introduction to our API, see the getting started guide. Backbone presets The following preset names correspond…

  • Errors

    FailedTrialError class Raise this error to mark a Trial as failed. When this error is raised in a Trial, the Tuner would not retry the Trial but directly mark it as “FAILED”. Example FatalError class A fatal error during search to terminate the program. It is used to terminate the KerasTuner program for errors that need users immediate attention. When this error is raised in…

  • KerasTuner HyperModels

    The HyperModel base class makes the search space better encapsulated for sharing and reuse. A HyperModel subclass only needs to implement a build(self, hp) method, which creates a keras.Model using the hp argument to define the hyperparameters and returns the model instance. A simple code example is shown as follows. You can pass a HyperModel instance to the Tuner as the search space. There are also some built-in HyperModel subclasses (e.g. HyperResNet, HyperXception)…

  • KerasTuner Oracles

    The Oracle class is the base class for all the search algorithms in KerasTuner. An Oracle object receives evaluation results for a model (from a Tuner class) and generates new hyperparameter values. The built-in Oracle classes are RandomSearchOracle, BayesianOptimizationOracle, and HyperbandOracle. You can also write your own tuning algorithm by subclassing the Oracle class.

  • The Tuner classes in KerasTuner

    The base Tuner class is the class that manages the hyperparameter search process, including model creation, training, and evaluation. For each trial, a Tuner receives new hyperparameter values from an Oracle instance. After calling model.fit(…), it sends the evaluation results back to the Oracle instance and it retrieves the next set of hyperparameters to try. There are a few built-in Tuner subclasses available for widely-used tuning…

  • HyperParameters

    HyperParameters class Container for both a hyperparameter space, and current values. A HyperParameters instance can be pass to HyperModel.build(hp) as an argument to build a model. To prevent the users from depending on inactive hyperparameter values, only active hyperparameters should have values in HyperParameters.values. Attributes Boolean method Choice between True and False. Arguments Returns The value of the hyperparameter, or None if…

  • Keras configuration utilities

    version function clear_session function Resets all state generated by Keras. Keras manages a global state, which it uses to implement the Functional model-building API and to uniquify autogenerated layer names. If you are creating many models in a loop, this global state will consume an increasing amount of memory over time, and you may want to clear…