Category: Keras

  • Using model.fit() instead of fit_generator() with Data Generators – TF.Keras

    Using model.fit() instead of fit_generator() with Data Generators – TF.Keras

    If you have been using data generators in Keras, such as ImageDataGenerator for augment and load the input data, then you would be familiar with the using the *_generator() methods (fit_generator(), evaluate_generator(), etc.) to pass the generators when trainning the model.  But recently, if you have switched to TensorFlow 2.1 or later (and tf.keras), you might…

  • Fixing the KeyError: ‘acc’ and KeyError: ‘val_acc’ Errors in Keras 2.3.x

    Have you been using the ‘History’ object returned by the fit() functions of Keras to graph or visualize the training history of your models? And have you been getting a ‘KeyError’ type error such as the following since recent Keras upgrade and wondering why? Traceback (most recent call last): File “lenet_mnist_keras.py”, line 163, in <module>…

  • TensorFlow 2.0 Released!

    After months in the Alpha state, Google has now released the final stable version of TensorFlow 2.0. TensorFlow 2.0 aims at providing a easy to use yet flexible and powerful machine learning platform. The new version also hopes to simplify deployment of TF models to any platform by standardizing the model formats. You will be…

  • Using Data Augmentations in Keras

    When I did the article on Using Bottleneck Features for Multi-Class Classification in Keras and TensorFlow, a few of you asked about using data augmentation in the model. So, I decided to do few articles experimenting various data augmentations on a bottleneck model. As a start, here’s a quick tutorial explaining what data augmentation is, and…

  • Migrating a Model to Keras 2.0

    Keras v2.0 has been released for a couple of months now – v2.0.0 released on 5th May, 2017, while the latest version is 2.0.8 at the time of this writing. It brought in a lot of new features and improvements, but also made some syntax changes. Trying to run a code with the old syntax…

  • What is the image_data_format parameter in Keras, and why is it important

    We’ve talked about the image_dim_ordering parameter in Keras and why is it important. But since from Keras v2 changed the name of the parameter, I thought of bringing this up again. As you know, Keras  is a higher-level neural networks library for Python, which is capable of running on top of TensorFlow, CNTK (Microsoft Cognitive…

  • Using Bottleneck Features for Multi-Class Classification in Keras and TensorFlow

    Training an Image Classification model – even with Deep Learning – is not an easy task. In order to get sufficient accuracy, without overfitting requires a lot of training data. If you try to train a deep learning model from scratch, and hope build a classification system with similar level of capability of an ImageNet-level…

  • image_data_format vs. image_dim_ordering in Keras v2

    If you have been using Keras for some time, then you would probably know the image_dim_ordering parameter of Keras. Specially, if you switch between TensorFlow and Theano backends frequently when using Keras. When I first started using Keras for image classification, most of my experiments failed because I have set the image_dim_ordering incorrectly. Learning from…

  • Visualizing Keras Models – Updated

    About 2 months back, I did a post on how you can visualize the structure of a Keras model. As I mentioned, when the machine learning (or deep learning) model you’re building is complex, then it may be easier to understand it if you can see a visual representation of it. I showed you how…