I had a go writing conv nets in J.
See
https://github.com/jonghough/jlearn/blob/master/adv/conv2d.ijs
This uses ;.3 to do the convolutions. Using a version of this , with a couple
of fixes, I managed to get 88% accuracy on the cifar-10 imageset. Took several
days to run, as my algorithms are not optimized in any way, and no gpu was
used.
If you look at the references in the above link, you may get some ideas.
the convolution verb is defined as:
cf=: 4 : 0
|:"2 |: +/ x filter&(convFunc"3 3);._3 y
)
Note that since the input is an batch of images, each 3-d (width, height,
channels), we are actually doing the whole forward pass over a 4d array, and
outputting another 4d array of different shape, depending on output channels,
filter width, and filter height.
Thanks,
Jon
On Saturday, April 13, 2019, 7:25:16 AM GMT+9, Brian Schott
<[email protected]> wrote:
As near as I can tell im2col is a matlab utility used by convolutional
neural network developers to transform a 2D image into a column vector. It
relies on u;.3 's subarray skills to "slide" through a 2D image.
I am experimenting with very small 3by4 pseudo-images and have created the
code below for my application. I found it very annoying to create my verbs
to work with both 12 item lists and with tables built on 12 columns. I'm
wondering if there is a simpler way to do what I show below. My verb im2col
assume that a 2x2 "filter" is being slid around with a 1 unit "stride" and
no "zero padding" and at present I do not need more generality than that.
My sense is unnecessarily using boxing and I dislike the heavy use of the
rank conjunction. But I fear I am at the limit of my ability with this
complicated im2col and forcearray, so suggestions would be welcome.
(Btw, my righthand argument is just for development, not real.)
forcearray =: (($,)~_2{.1,$)
im2col =: (2 2$1 1 2 2) (|:"2@:(,;._3)"2) _4 ]\"1 ]
$,"1&>/"1<"2 im2col forcearray i.12
1 4 6
$,"1&>/"1<"2 im2col forcearray i.2 12
2 4 6
$,"1&>/"1<"2 im2col forcearray i.3 12 NB. etc
3 4 6
,"1&>/"1<"2 im2col forcearray i.2 12
0 1 2 4 5 6
1 2 3 5 6 7
4 5 6 8 9 10
5 6 7 9 10 11
12 13 14 16 17 18
13 14 15 17 18 19
16 17 18 20 21 22
17 18 19 21 22 23
,"1&>/"1<"2 im2col forcearray i. 12
0 1 2 4 5 6
1 2 3 5 6 7
4 5 6 8 9 10
5 6 7 9 10 11
im2col is described in the link.
http://cs231n.github.io/convolutional-networks/
Thanks,
--
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm