This notebook shows how to build a Convolutional Neural Network (CNN) for flower classification using TensorFlow and Keras Tuner. It uses the tf_flowers dataset, which contains images of five different flower types: dandelion, daisy, tulips, sunflowers, and roses.
The notebook is organized into the following sections:
- Finding the dataset: Loads the
tf_flowersdataset using TensorFlow Datasets and displays some sample images. - Initial data processing: Preprocesses the images by resizing and normalizing them. Splits the data into training, validation, and test sets.
- Writing a simple convolutional network without a tuner: Builds a basic CNN model and trains it on the training data. Evaluates the model's performance on the test set.
- Finding CNN using tuner: Uses Keras Tuner to find the optimal hyperparameters for the CNN model. This involves defining a search space for the hyperparameters and using a Bayesian Optimization algorithm to explore the search space.
- TensorBoard: Visualizes the training process and hyperparameter tuning results using TensorBoard.
- Python 3.7 or higher
- TensorFlow
- TensorFlow Datasets
- Keras Tuner
- Matplotlib
- NumPy
- Make sure you have all the required libraries installed. You can install them using
pip: - Open the notebook in Google Colab or Jupyter Notebook.
- Run the cells in the notebook cell by cell.
- To view the TensorBoard visualizations, you need to replace /content/tf_flowers/bayesian_opt20241210-195027 with your actual path:
My Tensorboard plots for accuracy and loss (for 10 different Hyperband trials with training and validation).
- Accuracy
- Loss

