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