Generating Linux kernel code with a GRU

We will now look at a simple, fun example, to generate Linux kernel code using an RNN. The complete Jupyter Notebook for this example is available in the book's code repository, under Chapter08. For the training data, we will first extract the kernel code from the Linux source. You can download the latest (or an earlier) version of the Linux kernel from the kernel archives at

We will extract the tar file and use only the core kernel under the kernel/directory in the source. Execute the following from the root directory of the kernel tree to extract code from all of the *.c files:

cd kernelfind . -name "*.c" -exec cat >> /tmp/kernel.txt {} \;

This will concatenate all of ...

Get Hands-On Natural Language Processing with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.