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.



Yes you can vectorize a CNN. See this github file for details: https://github.com/parasdahal/deepnet/blob/master/deepnet/layers.py

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!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.