README.org

May 25, 2018 ยท View on GitHub

  • MNIST classification live demo

This repository contains a simple demo showcasing training of a simple MLP on the [[http://yann.lecun.com/exdb/mnist/][MNIST]] dataset.

This demo is part of a talk given at the [[https://www.iap.uni-bonn.de/forms/weekend/program][BCGS weekend seminar]] in Bad Honnef on <2018-05-26 Sa>.

The basic idea is the following:

** Simple gif of the live demo

[[file:media/demo.gif]]

** Breakdown of repo / project

  • [[ann_talk.org]] is the talk I will be giving
    • =ann_talk.pdf= the corresponding PDF. It's created via org-beamer export
  • [[src]]: contains the Nim code
    • [[src/clientPlotly.nim]]: The Nim program, which compiles to javascript and performs live plotting of the data it's being sent
    • [[src/index_style.html]] The Html template, which runs the compiled =clientPlotly.js=
    • [[src/server.nim]] The Nim program, which compiles to C and trains the MLP and sends the data to clientPlotly.js
    • [[src/protocol.nim]] The (very simple) protocol used to transfer the data between the two programs using =WebSocket=
    • [[src/resources]]: A folder containing a file, which contains data used to initialize the plots.

The demo consists of 2 different programs, a client and a server. The server performs the actual training using Arraymancer. The client is only used to plot the data. It uses nim-plotly (based on plotly.js) for that.

*** Client Since nim-plotly by default uses the =C= backend, some work had to be done to be able to produce live updating plots. Using a static template.html does not easily allow to call =Plotly.react= to replace the content of the plot. Therefore, we use an experimental JS backend for nim-plotly and call =newPlot= as well as =react= from that. But because we cannot train the MLP using the JS backend, we need to split the two into individual programs. The communication between the two happens using WebSockets, with the data being sent as stringified JSON.

Note that this depends on the =nim-plotly/exp_js_backend= branch here: [[https://github.com/vindaar/nim-plotly/tree/exp_js_backend]].