This repository contains a simple demo showcasing training of a simple MLP on the MNIST dataset.
This demo is part of a talk given at the BCGS weekend seminar in Bad Honnef on <2018-05-26 Sa>.
The basic idea is the following:
- train MLP using Arraymancer
- after each epoch (or more or less often?) take (some?) random digit, classifiy
- use plotly (Nim interface to plotly.js) to plot sample as heatmap on the fly, including prediction of network of that sample
- 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.
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.