Is it possible to vectorise a CNN?


I am trying to write a CNN from scratch and am wondering if it possible to vectorise the convolution step.

For example, if I had a dataset of 500 RGB images of size 32x32x3, and wanted the first conv layer to have 64 filters, how would I go about vectorisation.

Currently, I am running through all 500 images in a 'for' loop, convoluting individually. I do this for all the images up to the flattening stage (where it essentially becomes a normal NN again), at which point I can implement the normal vectorisation approach to get to my output etc.

A holistic overview of the process would be appreciated as I am struggling to get my head around it and am struggling to find and information on the matter online.



Posted 2019-11-04T00:06:14.980

Reputation: 157



Yes you can vectorize a CNN. See this github file for details:

After looking through it it basically transposes the input to some dimension and apply matrix multiplication to the weight with some other kind of transfromation. Pls refer to the github repository for details.

Hope this can help you and have a nice day!

Clement Hui

Posted 2019-11-04T00:06:14.980

Reputation: 1 593