DecodeAI
← Question Bank

Deep Learning & Generative AI

Convolution Neural Networks

Interview questions on Convolution Neural Networks.

14 questions

Convolution and Correlation

Q1. This Equation is commonly used in image processing:

Sign in to bookmark

(fg)(t)=f(τ)g(tτ)dτ(f * g)(t) = \int_{-\infty}^{\infty} f(\tau)g(t - \tau)d\tau

  1. What does the above equation represent?
  2. What does g(t)g(t) represent?

Convolution and Correlation

Q2. A data-scientist assumes that:

Sign in to bookmark
  1. A convolution operation is both linear and shift invariant.
  2. A convolution operation is just like correlation, except that we flip over the filter before applying the correlation operator.
  3. The convolution operation reaches a maximum, only in cases where the filter is mostly similar to a specific section of the input signal. Is he right in assuming so? Explain in detail the meaning of these statements.

Convolution and Correlation

Q3. Mark the correct choice(s):

Sign in to bookmark
  1. The cross-correlation operator is used to find the location where two different signals are most similar.
  2. The autocorrelation operator is used to find when a signal is similar to a delayed version of itself.

Convolution and Correlation

Q4. A data-scientist provides you with a formulae for a discrete 2D convolution operation

Sign in to bookmark

f(x,y)h(x,y)=m=0M1n=0N1f(m,n)h(xm,yn)f(x,y) * h(x,y) = \sum_{m=0}^{M-1} \sum_{n=0}^{N-1} f(m,n)h(x - m, y - n) Using above, write the equivalent 2D correlation operation.

Convolution and Correlation

Q5. When designing a convolutional neural network layer, one must also define how the filter or kernel slides through the input signal. This is controlled by what is known as the stride and padding parameters or modes. The two most commonly used padding approached in convolutions are the VALID and the SAME modes. Given an input stride of 1:

Sign in to bookmark
  1. Define SAME
  2. Define VALID

Convolution and Correlation

Q6. **True or False:** A valid convolution is a type of convolution operation that does not use any padding on the input.

Sign in to bookmark

Convolution and Correlation

Q7. You are provided with a $K × K$ input signal and a $θ × θ$ filter. The signal is subjected to the valid padding mode convolution. What are the resulting dimensions?$$

Sign in to bookmark

\begin{equation} A = \begin{bmatrix} 0 & 0 & \ldots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \ldots & 0 \\ \end{bmatrix} \tag{8.4} \end{equation}

Convolution and Correlation

Q8. As depicted in below figure, a filter is applied to $a × 3$ input signal. Identify the correct choice given a stride of 1 and Same padding mode. <table align='center'> <tr> <td align="center"> <img src="img/padding-1.png" alt= "Figure 8.3: A padding approach" style="max-width:70%;" /> </td> </tr> <tr> <td align="center"> Figure 8.3: A padding approach </td> </tr> </table>

Sign in to bookmark

Convolution and Correlation

Q9. As depicted in in (8.5), a filter is applied to a 3 × 3 input signal, mark the correct choices given a stride of 1. 1. A represents a VALID convolution and B represents a SAME convolution 2. A represents a SAME convolution and B represents a VALID convolution 3. Both A and B represent a VALID convolution 4. Both A and B represent a SAME convolution <table align='center'> <tr> <td align="center"> <img src="img/padding-1.png" alt= "Figure 8.4: A padding approach" style="max-width:70%;" /> </td> </tr> <tr> <td align="center"> Figure 8.4: A padding approach </td> </tr> </table>

Sign in to bookmark

Convolution and Correlation

Q10. In this question we discuss the two most commonly used padding approaches in convolutions; `VALID` and `SAME` . Below python code for generating an input signal arr001 and a convolution kernel filter001. ```python import numpy import scipy.signal arr01 = numpy.zeros((6, 6),dtype=float) print (arr01) arr01[:,:3] = 3.0 arr01[:,3:] = 1.0 filter001 = numpy.zeros((3, 3), dtype=float) filter001[:,0] = 2.0 filter001[:,2] = -2.0 output = scipy.signal.convolve2d(arr01, filter, mode='valid') ``` The input signal, arr001 is first initialized to all zeros as follows:$$

Sign in to bookmark

arr001 = \begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 \\ \end{bmatrix}

Convolution and Correlation

Q11. Equation 8.6 is the discrete equivalent of equation 8.2 which is frequently used in image processing:$$

Sign in to bookmark

\begin{equation} f(x,y) * h(x,y) = \sum_{m=0}^{M-1} \sum_{n=0}^{N-1} f(m,n)h(x - m, y - n) \tag{8.6} \end{equation} 1.GiventhefollowingdiscretekernelintheXdirection,whatwouldbetheequivalentYdirection?1. Given the following discrete kernel in the X direction, what would be the equivalent Y direction? K = \frac{1}{2} \begin{bmatrix} -1 & 1 \\ -1 & 1 \end{bmatrix}

Convolution and Correlation

Q12. Given an image of size $w × h $, and a kernel with width$ K$ , how many multiplications and additions are required to convolve the image?

Sign in to bookmark

Convolution and Correlation

Q13. Presents two built-in Python functions for the convolution and correlation operators. ```python import nympy as np np.convolve(A,B,"full") # for convolution np.correlate(A,B,"full") # for cross correlation ``` 1. Implement the convolution operation from scratch in Python. Compare it with the built-in numpy equivalent. 2. Implement the correlation operation using the implementation of the convolution operation. Compare it with the built-in numpy equivalent.

Sign in to bookmark

Convolution and Correlation

Q14. The Gaussian distribution in the 1D and 2D is shown in Equations 8.8 and 8.9.$$

Sign in to bookmark

\begin{equation} G(x) = \sqrt\frac{1}{2\pi\sigma^2}e^{-\frac{x^2}{2\sigma^2}} \tag{8.8} \end{equation}

\begin{equation} G(x, y) = \sqrt\frac{1}{2\pi\sigma^2}e^{-\frac{x^2+y^2}{2\sigma^2}} \tag{8.9} \end{equation} $$The Gaussian filter, is an operator that is used to blur images and remove detail and noise while acting like a low-pass filter. This is similar to the way a mean filter works, but the Gaussian filter uses a different kernel. This kernel is represented with a Gaussian bell shaped bump. Answer the following questions: 1. Can 8.8 be used directly on a 2D image? 2. Can 8.9 be used directly on a 2D image? 3. Is the Gaussian filter separable? if so, what are the advantages of separable filters.