keras

Topics related to keras:

Getting started with keras

Guiding principles

  • Modularity

A model is understood as a sequence or a graph of standalone, fully-configurable modules that can be plugged together with as little restrictions as possible. In particular, neural layers, cost functions, optimizers, initialization schemes, activation functions, regularization schemes are all standalone modules that you can combine to create new models.

  • Minimalism

Each module should be kept short and simple. Every piece of code should be transparent upon first reading. No black magic: it hurts iteration speed and ability to innovate.

  • Easy extensibility

New modules are dead simple to add (as new classes and functions), and existing modules provide ample examples. To be able to easily create new modules allows for total expressiveness, making Keras suitable for advanced research.

  • Work with Python

No separate models configuration files in a declarative format. Models are described in Python code, which is compact, easier to debug, and allows for ease of extensibility.

Create a simple Sequential Model

Dealing with large training datasets using Keras fit_generator, Python generators, and HDF5 file format

This example assumes keras, numpy (as np), and h5py have already been installed and imported. It also assumes that video inputs and labels have already been processed and saved to the specified HDF5 file, in the format mentioned, and a video classification model has already been built to work with the given input.

Classifying Spatiotemporal Inputs with CNNs, RNNs, and MLPs

In this example, a VGG-16 model pre-trained on the ImageNet database was used. If a trainable VGG-16 model is desired, set the VGG-16 weights parameter to None for random initialization and set the cnn.trainable attribute to True.

The number and kind of layers, units, and other parameters should be tweaked as necessary for specific application needs.

Custom loss function and metrics in Keras

Keras loss functions are defined in losses.py

Additional loss functions for Keras can be found in keras-contrib repository.

Transfer Learning and Fine Tuning using Keras