TransWikia.com

Help required in understanding how the error of a convolutional layer is calculated when filter and delta of next layer have differing dimensions

Data Science Asked by adhok on September 5, 2021

I am trying to implement a CNN in NumPy so as to better understand its inner workings

My architecture is as follows

  • 10 images with 1 channel and with 28-pixel rows and columns (Dimension : (10X1X28X28))
  • 3 convolutional filters. Each with the dimension 5X5. (Dimension: 3X1X5X5)(stride=1)
  • First Convolutional Output with dimension (10X3X24X24)
  • First Max Pooling Layer(stride=2)
  • First Max Pooling Output with dimension (10X3X12X12)
  • 6 convolutional filters. Each with the dimension 3X5X5 (Dimension : 6X3X5X5) (stride=1)
  • Second Convolutional Output with dimension (10X6X8X8)
  • Second Max Pooling Layer(stride=2)
  • Second Max Pooling Output with dimension (10X6X4X4)
  • First Fully Connected Layer of Dimension (96X10)
  • Second Fully Connected Layer of Dimension (80X10)
  • Output Layer of Dimension (10X10)(Softmax Layer)

Using backpropagation, I have been able to calculate the error of the second convolutional output, which has the dimensions 10X6X8X8. I need to calculate the error of the first max-pooling output. This involves the following steps

  1. Take the convolutional filter that connects the first max-pooling output and the second convolutional output. This has the dimensions (6X3X5X5).
  2. Rotate the 3rd and 4th axes by 180 degrees. In code that will beresulting_weight = np.rot90(np.rot90(weight,axes(2,3),axes=(2,3))
  3. This results in the new rotated matrix that has the dimensions (6X3X5X5)
  4. Do full convolution between the errors of second convolutional output(10X6X8X8) and the new rotated matrix(6X3X5X5)

I am unsure of how to implement the last step due to un-matching dimensions. The full convolutional operation should result in a matrix with the dimensions (10X3X12X12). This is made possible only if the rotated matrix has the dimensions (3X6X5X5). Should we re-shape the rotated matrix to have the dimensions (3X6X5X5)? Or is my understanding of the 180-degree rotation wrong?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP