Long Short-Term Memory Network using CNTK 2.0

The Microsoft CNTK v 2.0 is a code library for deep neural networks. The library is written in C++ but you use CNTK by writing a Python program that calls into the CNTK functions.

I took a look at the documentation example for a long short-term memory (LSTM) recurrent neural network. When I want to understand a library, my first step is to get a program to run. After that, I can start experimenting with the program. That’s the most effective approach for me anyway.

The CNTK example was written as a IPYNB (interactive Python notebook) file. I much prefer ordinary Python programs, so I set out to refactor the notebook code to plain Python.

It took me about an hour but I eventually got the LSTM network demo running. The first part of the example generates data using the sine function:

The second part of the example creates, trains, and evaluates a LSTM prediction model:

OK, so I got the example running, but at this point I have pretty much zero understanding of what’s going on. But I’ve made the first step.

This entry was posted in CNTK, Machine Learning. Bookmark the permalink.