Function Reference
 Keras Models
 Core Layers
 Convolutional Layers
 Pooling Layers
 Activation Layers
 Dropout Layers
 Locallyconnected Layers
 Recurrent Layers
 Embedding Layers
 Normalization Layers
 Noise Layers
 Merge Layers
 Layer Wrappers
 Layer Methods
 Custom Layers
 Model Persistence
 Datasets
 Applications
 Sequence Preprocessing
 Text Preprocessing
 Image Preprocessing
 Optimizers
 Callbacks
 Initializers
 Constraints
 Utils
 Losses
 Metrics
 Regularizers
 Activations
Keras Models 


Keras Model 

Keras Model composed of a linear stack of layers 

Print a summary of a Keras model 

Configure a Keras model for training 

Train a Keras model 

Fits the model on data yielded batchbybatch by a generator. 

Evaluate a Keras model 

Evaluates the model on a data generator. 

Generate predictions from a Keras model 

Generates probability or class probability predictions for the input samples. 

Returns predictions for a single batch of samples. 

Generates predictions for the input samples from a data generator. 

Single gradient update or model evaluation over one batch of samples. 

Retrieves a layer based on either its name (unique) or index. 

Remove the last layer in a model 

Save/Load models using HDF5 files 

Core Layers 

Input layer 

Add a denselyconnected NN layer to an output 

Apply an activation function to an output. 

Applies Dropout to the input. 

Reshapes an output to a certain shape. 

Permute the dimensions of an input according to a given pattern 

Repeats the input n times. 

Wraps arbitrary expression as a layer 

Layer that applies an update to the cost function based input activity. 

Masks a sequence by using a mask value to skip timesteps. 

Flattens an input 

Convolutional Layers 

1D convolution layer (e.g. temporal convolution). 

Transposed 2D convolution layer (sometimes called Deconvolution). 

2D convolution layer (e.g. spatial convolution over images). 

Transposed 3D convolution layer (sometimes called Deconvolution). 

3D convolution layer (e.g. spatial convolution over volumes). 

Convolutional LSTM. 

Depthwise separable 2D convolution. 

Upsampling layer for 1D inputs. 

Upsampling layer for 2D inputs. 

Upsampling layer for 3D inputs. 

Zeropadding layer for 1D input (e.g. temporal sequence). 

Zeropadding layer for 2D input (e.g. picture). 

Zeropadding layer for 3D data (spatial or spatiotemporal). 

Cropping layer for 1D input (e.g. temporal sequence). 

Cropping layer for 2D input (e.g. picture). 

Cropping layer for 3D data (e.g. spatial or spatiotemporal). 

Pooling Layers 

Max pooling operation for temporal data. 

Max pooling operation for spatial data. 

Max pooling operation for 3D data (spatial or spatiotemporal). 

Average pooling for temporal data. 

Average pooling operation for spatial data. 

Average pooling operation for 3D data (spatial or spatiotemporal). 

Global max pooling operation for temporal data. 

Global average pooling operation for temporal data. 

Global max pooling operation for spatial data. 

Global average pooling operation for spatial data. 

Global Max pooling operation for 3D data. 

Global Average pooling operation for 3D data. 

Activation Layers 

Apply an activation function to an output. 

Leaky version of a Rectified Linear Unit. 

Parametric Rectified Linear Unit. 

Thresholded Rectified Linear Unit. 

Exponential Linear Unit. 

Dropout Layers 

Applies Dropout to the input. 

Spatial 1D version of Dropout. 

Spatial 2D version of Dropout. 

Spatial 3D version of Dropout. 

Locallyconnected Layers 

Locallyconnected layer for 1D inputs. 

Locallyconnected layer for 2D inputs. 

Recurrent Layers 

Fullyconnected RNN where the output is to be fed back to input. 

Gated Recurrent Unit  Cho et al. 

LongShort Term Memory unit  Hochreiter 1997. 

Embedding Layers 

Turns positive integers (indexes) into dense vectors of fixed size. 

Normalization Layers 

Batch normalization layer (Ioffe and Szegedy, 2014). 

Noise Layers 

Apply additive zerocentered Gaussian noise. 

Apply multiplicative 1centered Gaussian noise. 

Applies Alpha Dropout to the input. 

Merge Layers 

Layer that adds a list of inputs. 

Layer that multiplies (elementwise) a list of inputs. 

Layer that averages a list of inputs. 

Layer that computes the maximum (elementwise) a list of inputs. 

Layer that concatenates a list of inputs. 

Layer that computes a dot product between samples in two tensors. 

Layer Wrappers 

Apply a layer to every temporal slice of an input. 

Bidirectional wrapper for RNNs. 

Layer Methods 

Layer/Model configuration 

Layer/Model weights as R arrays 


Retrieve tensors for layers with multiple nodes 
Count the total number of scalars composing the weights. 

Reset the states for a layer 

Custom Layers 

Base R6 class for Keras layers 

Create a Keras Layer 

Model Persistence 

Save/Load models using HDF5 files 

Save/Load model weights using HDF5 files 

Serialize a model to an R object 

Layer/Model weights as R arrays 

Layer/Model configuration 

Model configuration as JSON 

Model configuration as YAML 

Datasets 

CIFAR10 small image classification 

CIFAR100 small image classification 

IMDB Movie reviews sentiment classification 

Reuters newswire topics classification 

MNIST database of handwritten digits 

Boston housing price regression dataset 

Applications 

Xception V1 model for Keras. 

Inception V3 model, with weights pretrained on ImageNet. 

VGG16 and VGG19 models for Keras. 

ResNet50 model for Keras. 


MobileNet model architecture. 
Preprocesses a tensor encoding a batch of images. 

Decodes the prediction of an ImageNet model. 

Sequence Preprocessing 

Pads each sequence to the same length (length of the longest sequence). 

Generates skipgram word pairs. 

Generates a word rankbased probabilistic sampling table. 

Text Preprocessing 

Text tokenization utility 

Update tokenizer internal vocabulary based on a list of texts or list of sequences. 

Transform each text in texts in a sequence of integers. 

Transforms each text in texts in a sequence of integers. 

Convert a list of texts to a matrix. 

Convert a list of sequences into a matrix. 

Onehot encode a text into a list of word indexes in a vocabulary of size n. 

Converts a text to a sequence of indexes in a fixedsize hashing space. 

Convert text to a sequence of words (or tokens). 

Image Preprocessing 

Loads an image into PIL format. 

Converts a PIL Image instance to a 3darray. 

Generate minibatches of image data with realtime data augmentation. 

Fit image data generator internal statistics to some sample data. 

Generates batches of augmented/normalized data from image data and labels 

Generates batches of data from images in a directory (with optional augmented/normalized data) 

Optimizers 

Stochastic gradient descent optimizer 

RMSProp optimizer 

Adagrad optimizer. 

Adadelta optimizer. 

Adam optimizer 

Adamax optimizer 

Nesterov Adam optimizer 

Callbacks 

Callback that prints metrics to stdout. 

Save the model after every epoch. 

Stop training when a monitored quantity has stopped improving. 

Callback used to stream events to a server. 

Learning rate scheduler. 

TensorBoard basic visualizations 

Reduce learning rate when a metric has stopped improving. 

Callback that terminates training when a NaN loss is encountered. 

Callback that streams epoch results to a csv file 

Create a custom callback 

Base R6 class for Keras callbacks 

Initializers 

Initializer that generates tensors initialized to 0. 

Initializer that generates tensors initialized to 1. 

Initializer that generates tensors initialized to a constant value. 

Initializer that generates tensors with a normal distribution. 

Initializer that generates tensors with a uniform distribution. 

Initializer that generates a truncated normal distribution. 

Initializer capable of adapting its scale to the shape of weights. 

Initializer that generates a random orthogonal matrix. 

Initializer that generates the identity matrix. 

Glorot normal initializer, also called Xavier normal initializer. 

Glorot uniform initializer, also called Xavier uniform initializer. 

He normal initializer. 

He uniform variance scaling initializer. 

LeCun uniform initializer. 

LeCun normal initializer. 

Constraints 

MaxNorm weight constraint 

NonNeg weight constraint 

UnitNorm weight constraint 

MinMaxNorm weight constraint 

Utils 

Plot training history 

Converts a class vector (integers) to binary class matrix. 

Convert to NumPy Array 

Normalize a matrix or ndarray 

Representation of HDF5 dataset to be used instead of an R array 

Downloads a file from a URL if it not already in the cache. 

Keras backend tensor engine 

Keras implementation 

Install Keras and the TensorFlow backend 

Check if Keras is Available 

Losses 


Model loss functions 
Metrics 


Model performance metrics 
Regularizers 

L1 and L2 regularization 

Activations 


Activation functions 