- Keras and TensorFlow are the state of the art in deep learning tools and with the keras package you can now access both with a fluent R interface.
- To prepare this data for training we one-hot encode the vectors into binary class matrices using the Keras function:
The core data structure of Keras is a model, a way to organize layers.

- We begin by creating a sequential model and then adding layers using the pipe ( ) operator:
The argument to the first layer specifies the shape of the input data (a length 784 numeric vector representing a grayscale image).

- Use the function to print the details of the model:
Next, compile the model with appropriate loss function, optimizer, and metrics:

Use the function to train the model for 30 epochs using batches of 128 images:

The object returned by includes loss and accuracy metrics which we can plot:

Evaluate the model’s performance on the test data:

Keras provides a vocabulary for building deep learning models that is simple, elegant, and intuitive.

- After you’ve become familiar with the basics, these articles are a good next step:
Keras provides a productive, highly flexible framework for developing deep learning models.

We are excited to announce that the keras package is now available on CRAN. The package provides an R interface to Keras, a high-level neural networks API developed with a focus on enabling fast experimentation. Keras has the following key features:

Continue reading “Keras for R”