reshown by
9,102 views
5 5 votes

Assume we have a $5\times5$ px RGB image with 3 channels respectively for R, G, and B. If

R
2 0 0 0 0
1 2 0 0 1
2 0 1 0 2
1 2 1 0 1
0 1 0 2 0
G
0 2 1 2 2
1 1 1 0 0
0 0 2 2 0
2 0 0 2 0
0 2 1 1 1
B
0 1 0 0 1
1 1 2 0 1
1 0 2 0 2
1 0 1 1 0
1 2 1 1 2

 

We have one $3\times3$ px kernel (filter) with 3 channels as follows:

Filter - R
0 0 1
1 0 1
1 0 0
Filter - G
0 0 -1
1 0 0
1 -1 0
Filter - B
1 0 1
0 1 -1
1 -1 0

 

a) If Stride = 2, and Zero-padding = 1, and Bias = 1, what will be the result of convolution?

b) What is the result after applying a ReLU layer ($max(z,0)$)on the result with the same size of the reuslt in part a?

c) Calculate the output by applying max-pooling layer with the size of $2\times2$ on the output of part b, and Stride = 1. (hint: max-pooling layer here and usually do not include any zero-paddings)

d) What is the result after applying flatten on the output of part c and creating a vector?

e) Assume the vector you created contains m elements. Consider it as the input vector for a Softmax Regression classifier (without any hidden layers and biases and it is fully connected). Assume there are 2 classes of 0 and 1. For all the weights from each element in the feature vector, the optimized weights are 1 for odd elements and 2 for even elements. For example, if the feature vector is [10,11,12,13,14], all the weights from 10 are 1 (because 10 is element 1 and 1 is odd), all the weights from 11 are 2, all the weights from 12 are 1, all the weights from 13 are 2 and all the weights from 14 are 1 and so on. Draw the Softmax Regression network and calculate the class should be 0 or 1?

Hint: 
Softmax Regression: $p_{i}=\frac{e^{z_{i}}}{\sum_{i=1}^{c} e^{z_{i}}}$
Where $p_{i}$ is the probability of class $i$ anc $c$ is the number of classes.

50% Accept Rate Accepted 31 answers out of 62 questions

1 Answer

Best answer
0 0 votes

Answers:

a)
The result is shown in the figure below. For an alternative question, when we have two $3\times3$ RGB kernels please take a look at Convolution Demo section of this page. The result is the Green matrix.

 

R:
0 2 0
2 2 0
3 3 2

G:
-1 2 2
-3 0 4
0 0 1

B:
-2 -1 0
1   2. 3
-1 1  3


Bias = 1

Result
-2 4 3
1  5  8
3 5  7

b) The result of part (a) is shown in the above image in Green matrix. The ReLU layer makes the negative elements 0, and do not change the rest of the elements. Therefore, the result is as follows:

ReLU of result
0 4 3
1 5 8
3 5 7

c) The result of max-pulling on ReLU with Stride = 1:

Max-pooling of ReLU
5 8
5 8

 

d) Flatten technique is shown in the figure below. Therefore, the result feature vector is $[5,8,5,8]$

e) The Softmax Regression network is shown in figure below. If you calculate the probabilities of class 0 and 1, both are 50%. Therefore, it could be both class 0 and class 1 with the same probability.

Related questions

3 3 votes
1 answers 1 answer
9.4k
9.4k views
tofighi asked Apr 4, 2019
9,399 views
In the figure below, a neural network is shown. Calculate the following:1) How many neurons do we have in the input layer and the output layer?2) How many hidden layers d...
3 3 votes
2 answers 2 answers
8.4k
8.4k views
tofighi asked Apr 4, 2019
8,400 views
The scatter plot of Iris Dataset is shown in the figure below. Assume Softmax Regression is used to classify Iris to Setosa, Versicolor, or Viriginica using just petal le...
3 3 votes
1 answers 1 answer
7.4k
7.4k views
tofighi asked Apr 11, 2019
7,392 views
Assume we have the following neural network and all activation functions are $f(z)=z$. If the weights are initialized with the values you see in table below, what will be...
3 3 votes
1 answers 1 answer
6.0k
6.0k views
tofighi asked Aug 10, 2020
6,004 views
The goal of backpropagation is to optimize the weights so that the neural network can learn how to correctly map arbitrary inputs to outputs.Assume for the following neur...
1 1 vote
1 answers 1 answer
3.6k
3.6k views
tofighi asked Oct 30, 2018
3,564 views
Both of the batch size and number of epochs are integer values and seem to do the same thing in Stochastic gradient descent. What are these two hyper-parameters of this l...