I had some fun putting J Playground through its paces and wrote the
following neural network demo:

https://jsoftware.github.io/j-playground/bin/html2#url=https://gist.githubusercontent.com/jpjacobs/6ff68c07bf764ad886e097ffbd19f5f0/raw/52b0563a7daa76df7fa57a3743da45ca0755f1a7/nn.ijs

It dowloads the CSV and DSV packages and the Spirals dataset, normalises
the data and applies some random jitter.
The neural network can be given any number of layers of any size (of
course, respecting the input layer to be of size 2 and the output layer of
size 3,as there are 2 input dimensions and 3 labels, one-hot encoded), e.g.
net=: nn 2 15 8 3
It is trained with stochastic gradient descent and backpropagation with
quadratic loss, using e.g. 5000 100 0.1 sgd__net spl =: splitdata data ,.
labels
When finished, it outputs some stats and some nice pictures of the data and
classification borders, using report__net spl.

I was **very** impressed to see it run (entire script with 5000 training
epochs, and visualisation) without going out of memory in under 35 secs on
my mid-range phone… just wow.

Some things I noted with respect to the playground:
- I had to patch the enclength_jzlib_ verb to allow bigger viewmat pictures
(see at the bottom of the script).
- It's a pity the text output is blocked until all calculations are done,
as this renders it impossible to give status updates. Is there a trick like
in JQt (wd 'msgs') to overcome this?
- Maybe related: plots and text output do not keep their relative output
positions, which I think would be desirable when trying to make a coherent
example.
- The plot quality is not great yet, while I saw j901 on iPadOS seems to
get vector graphics from plot. As the Playground would be the showcase of
J, it would be great if it could also include crisp graphics.
- Lastly, I noted some strange scrolling glitches after running the script
in chrome on Windows (didn't try elsewhere): when scrolling up the terminal
output would jump back down from time to time.

Any suggestions for improvement are of course welcome, though I kept the
features minimal to avoid making it too lengthy. To my taste, the report
function is for instance a bit too wordy, but necessary to show some
interesting graphs. If one were really ambitious, it could be turned into
something like: http://playground.tensorflow.org/ ( open source, by the
way).

I hope you have fun tinkering with the neural network!
Best regards
Jan-Pieter
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to