lecture 5_quiz



第 1 个问题

1. 第 1 个问题

For which of the following tasks can we expect that the problem of "dimension hopping" will occur (given that the data is input correctly)? Check all that apply.

第 2 个问题

2. 第 2 个问题

We have a convolutional neural network for images of 5 by 5 pixels. In this network, each hidden unit is connected to a different 4 x 4 region of the input image:

  • The first hidden unit, h_1h1, is connected to the upper left 4x4 portion of the input image (as shown below).
  • The second hidden unit, h_2h2, is connected to the upper right 4x4 portion of the input image (as shown below).
  • The third hidden unit, h_3h3, is connected to the lower left 4x4 portion of the input image (not shown in the diagram).
  • The fourth hidden unit, h_4h4, is connected to the lower right 4x4 portion of the input image (not shown in the diagram).

Because it's a convolutional network, the weights (connection strengths) are the same for all hidden units: the only difference between the hidden units is that each of them connects to a different part of the input image. In the second diagram, we show the array of weights, which are the same for each of the four hidden units.

For h_1h1, weight w_{11}w11 is connected to the top-left pixel, i.e. x_{11}x11, while for hidden unit h_2h2, weight w_{11}w11 connects to the pixel that is one to the right of the top left pixel, i.e. x_{12}x12.

Imagine that for some training case, we have an input image where each of the black pixels in the top diagram has value 1, and each of the white ones has value 0. Notice that the image shows a "3" in pixels.

扫描二维码关注公众号,回复: 1832755 查看本文章

The network has no biases. The weights of the network are given as follows:

w11w21w31w41=1=0=1=0w12w22w32w42=1=0=1=0w13w23w33w43=1=1=1=1w14w24w34w44=0=0=0=0

The hidden units are linear.

For the training case with that "3" input image, what is the output y_1,y_2,y_3,y_4y1,y2,y3,y4 of each of the four hidden units?

y_1 = 4y1=4y_2 = 2y2=2y_3=8y3=8y_4=4y4=4

y_1 = 4y1=4y_2 = 4y2=4y_3=4y3=4y_4=4y4=4

y_1 = 2y1=2y_2 = 4y2=4y_3=4y3=4y_4=8y4=8

第 3 个问题

3. 第 3 个问题

Recall that pooling is the process of combining the outputs of several hidden units to create a single hidden unit. This introduces some invariance to local transformations in the input image.

In this example we are pooling hidden units h_1h1h_2h2, and h_3h3. Let's denote the output of hidden unit h_ihi as y_iyi. The hidden unit that we're creating by pooling is called h_\text{pool}hpool, with output y_\text{pool}ypoolSum pooling is defined as y_{\text{pool}} = y_1+y_2+y_3ypool=y1+y2+y3.

This form of pooling can be equivalently represented by making h_\text{pool}hpool a regular hidden unit that takes the output of the other three hidden units, multiplies them by some weights w_1w1w_2w2 and w_3w3, adds up the resulting numbers and then outputs some function of this sum. This is illustrated in the figure below.

For this to be equivalent to sum pooling, what type of neuron should h_\text{pool}hpool be, and what should the weights be?

w_1 = \frac{1}{3}w1=31w_2 = \frac{1}{3}w2=31w_3 = \frac{1}{3}w3=31, and h_\text{pool}hpool is a logistic neuron. 不正确

w_1 = 1w1=1w_2 = 1w2=1w_3 = 1w3=1, and h_\text{pool}hpool is a logistic neuron.

w_1 = 1w1=1w_2 = 1w2=1w_3 = 1w3=1, and h_\text{pool}hpool is a linear neuron.

第 4 个问题

4. 第 4 个问题

Suppose that we have a vocabulary of 3 words, "a", "b", and "c", and we want to predict the next word in a sentence given the previous two words. For this network, we don't want to use feature vectors for words: we simply use the local encoding, i.e. a 3-component vector with one entry being 11 and the other two entries being 00.

In the language models that we have seen so far, each of the context words has its own dedicated section of the network, so we would encode this problem with two 3-dimensional inputs. That makes for a total of 6 dimensions. For example, if the two preceding words (the "context" words) are "c" and "b", then the input would be (0, 0, 1, 0, 1, 0)(0,0,1,0,1,0). Clearly, the more context words we want to include, the more input units our network must have. More inputs means more parameters, and thus increases the risk of overfitting. Here is a proposal to reduce the number of parameters in the model:

Consider a single neuron that is connected to this input, and call the weights that connect the input to this neuron w_1,w_2,w_3,w_4,w_5w1,w2,w3,w4,w5, and w_6w6w_1w1 connects the neuron to the first input unit, w_2w2 connects it to the second input unit, etc. Notice how for every neuron, we need as many weights as there are input dimensions (6 in our case), which will be the number of words times the length of the context. A way to reduce the number of parameters is to tie certain weights together, so that they share a parameter. One possibility is to tie the weights coming from input units that correspond to the same word but at different context positions. In our example that would mean that w_1=w_4w1=w4w_2=w_5w2=w5, and w_3=w_6w3=w6

(see the "after" diagram below).

Are there any significant problems with this approach?

No: the new model after weight tying is an example of a convolutional neural network, and these are more powerful than a non-convolutional network because they are invariant to small transformations in the data.

Yes: weight tying only makes sense when we are working with images.

No: this method is an appropriate solution in that it will reduce the number of parameters and therefore always improve generalization.

第 5 个问题

5. 第 5 个问题

Let's look at what weight tying does to gradients, computed using the backpropagation algorithm. For this question, our network has three input units,

x_1,x_2,x_3x1,x2,x3, two logistic hidden units h_1,h_2h1,h2, four input to hidden weights w_1,w_2,w_3,w_4w1,w2,w3,w4, and two hidden to output weights

u_1,u_2u1,u2. The output neuron yy is a linear neuron, and we are using the squared error cost function.

Consider a single training case with target output tt. The sequence of computations required to compute the error (this is called forward

propagation) are as follows:

z1=z2=h1=h2=y=E=w1x1+w2x2w3x2+w4x3σ(z1)σ(z2)u1h1+u2h212(ty)2

EE is the error. Reminder: \sigma(x) = \frac{1}{1+\exp (-x)}σ(x)=1+exp(x)1

z_1z1 and z_2z2 are called the total inputs to hidden units h_1h1 and h_2h2 respectively.

Suppose we now decide to tie the weights so that w_2=w_3=w_{\text{tied}}w2=w3=wtied. What is the derivative of the error EE with respect to

w_{\text{tied}}wtied?

Hint: forget about weight tying for a moment and simply compute the derivatives \frac{\partial E}{\partial w_2}w2Eand \frac{\partial E}{\partial w_3}w3E.

Now set \frac{\partial E}{\partial w_{\text{tied}}}=\frac{\partial E}{\partial w_2}+\frac{\partial E}{\partial w_3}wtiedE=w2E+w3E.

\frac{\partial E}{\partial w_\text{tied}} = -2(t-y)(u_2 h_2(1-h_2)x_2)wtiedE=2(ty)(u2h2(1h2)x2)

\frac{\partial E}{\partial w_\text{tied}} = -2(t-y)(u_1 h_1(1-h_1)x_2)wtiedE=2(ty)(u1h1(1h1)x2) 不正确

\frac{\partial E}{\partial w_\text{tied}} = -(t-y)[u_1 h_1(1-h_1) + u_2 h_2(1-h_2)]x_2wtiedE=(ty)[u1h1(1h1)+u2h2(1h2)]x2 不正确

第 6 个问题

6. 第 6 个问题

Oh no! Brian's done it again! Claire had a dataset of 28 x 28 pixel handwritten digits nicely prepared to train a neural network, but Brian has gone and accidentally scrambled the images by re-ordering the pixels in some totally meaningless way, and now they can't get the original dataset back! Below is an image of a handwritten '2' before and after being scrambled by Brian.

BeforeAfter

Luckily, all of the images (in both the training set and the test set) were changed in the same way. For example, if pixels number 1 and number 3 switched places in one image, then they switched places in every other image as well. Because of that, Claire thinks that perhaps she can train a network after all.

Whether Claire is right or not depends largely on the type of neural network that she has in mind. Which of the following neural networks will be at a disadvantage because of Brian's mistake? Check all that apply.










第 1 个问题

1. 第 1 个问题

For which of the following tasks can we expect that the problem of "dimension hopping" will occur (given that the data is input correctly)? Check all that apply.

第 2 个问题

2. 第 2 个问题

We have a convolutional neural network for images of 5 by 5 pixels. In this network, each hidden unit is connected to a different 4 x 4 region of the input image:

  • The first hidden unit, h_1h1, is connected to the upper left 4x4 portion of the input image (as shown below).
  • The second hidden unit, h_2h2, is connected to the upper right 4x4 portion of the input image (as shown below).
  • The third hidden unit, h_3h3, is connected to the lower left 4x4 portion of the input image (not shown in the diagram).
  • The fourth hidden unit, h_4h4, is connected to the lower right 4x4 portion of the input image (not shown in the diagram).

Because it's a convolutional network, the weights (connection strengths) are the same for all hidden units: the only difference between the hidden units is that each of them connects to a different part of the input image. In the second diagram, we show the array of weights, which are the same for each of the four hidden units.

For h_1h1, weight w_{11}w11 is connected to the top-left pixel, i.e. x_{11}x11, while for hidden unit h_2h2, weight w_{11}w11 connects to the pixel that is one to the right of the top left pixel, i.e. x_{12}x12.

Imagine that for some training case, we have an input image where each of the black pixels in the top diagram has value 1, and each of the white ones has value 0. Notice that the image shows a "3" in pixels.

The network has no biases. The weights of the network are given as follows:

w11w21w31w41=1=0=1=0w12w22w32w42=1=0=1=0w13w23w33w43=1=1=1=1w14w24w34w44=0=0=0=0

The hidden units are linear.

For the training case with that "3" input image, what is the output y_1,y_2,y_3,y_4y1,y2,y3,y4 of each of the four hidden units?

y_1 = 4y1=4y_2 = 2y2=2y_3=8y3=8y_4=4y4=4

y_1 = 4y1=4y_2 = 4y2=4y_3=4y3=4y_4=4y4=4

y_1 = 2y1=2y_2 = 4y2=4y_3=4y3=4y_4=8y4=8

第 3 个问题

3. 第 3 个问题

Recall that pooling is the process of combining the outputs of several hidden units to create a single hidden unit. This introduces some invariance to local transformations in the input image.

In this example we are pooling hidden units h_1h1h_2h2, and h_3h3. Let's denote the output of hidden unit h_ihi as y_iyi. The hidden unit that we're creating by pooling is called h_\text{pool}hpool, with output y_\text{pool}ypoolSum pooling is defined as y_{\text{pool}} = y_1+y_2+y_3ypool=y1+y2+y3.

This form of pooling can be equivalently represented by making h_\text{pool}hpool a regular hidden unit that takes the output of the other three hidden units, multiplies them by some weights w_1w1w_2w2 and w_3w3, adds up the resulting numbers and then outputs some function of this sum. This is illustrated in the figure below.

For this to be equivalent to sum pooling, what type of neuron should h_\text{pool}hpool be, and what should the weights be?

w_1 = \frac{1}{3}w1=31w_2 = \frac{1}{3}w2=31w_3 = \frac{1}{3}w3=31, and h_\text{pool}hpool is a logistic neuron.

w_1 = 1w1=1w_2 = 1w2=1w_3 = 1w3=1, and h_\text{pool}hpool is a logistic neuron.

w_1 = 1w1=1w_2 = 1w2=1w_3 = 1w3=1, and h_\text{pool}hpool is a linear neuron.

第 4 个问题

4. 第 4 个问题

Suppose that we have a vocabulary of 3 words, "a", "b", and "c", and we want to predict the next word in a sentence given the previous two words. For this network, we don't want to use feature vectors for words: we simply use the local encoding, i.e. a 3-component vector with one entry being 11 and the other two entries being 00.

In the language models that we have seen so far, each of the context words has its own dedicated section of the network, so we would encode this problem with two 3-dimensional inputs. That makes for a total of 6 dimensions. For example, if the two preceding words (the "context" words) are "c" and "b", then the input would be (0, 0, 1, 0, 1, 0)(0,0,1,0,1,0). Clearly, the more context words we want to include, the more input units our network must have. More inputs means more parameters, and thus increases the risk of overfitting. Here is a proposal to reduce the number of parameters in the model:

Consider a single neuron that is connected to this input, and call the weights that connect the input to this neuron w_1,w_2,w_3,w_4,w_5w1,w2,w3,w4,w5, and w_6w6w_1w1 connects the neuron to the first input unit, w_2w2 connects it to the second input unit, etc. Notice how for every neuron, we need as many weights as there are input dimensions (6 in our case), which will be the number of words times the length of the context. A way to reduce the number of parameters is to tie certain weights together, so that they share a parameter. One possibility is to tie the weights coming from input units that correspond to the same word but at different context positions. In our example that would mean that w_1=w_4w1=w4w_2=w_5w2=w5, and w_3=w_6w3=w6

(see the "after" diagram below).

Are there any significant problems with this approach?

No: the new model after weight tying is an example of a convolutional neural network, and these are more powerful than a non-convolutional network because they are invariant to small transformations in the data.

Yes: weight tying only makes sense when we are working with images.

No: this method is an appropriate solution in that it will reduce the number of parameters and therefore always improve generalization.

第 5 个问题

5. 第 5 个问题

Let's look at what weight tying does to gradients, computed using the backpropagation algorithm. For this question, our network has three input units,

x_1,x_2,x_3x1,x2,x3, two logistic hidden units h_1,h_2h1,h2, four input to hidden weights w_1,w_2,w_3,w_4w1,w2,w3,w4, and two hidden to output weights

u_1,u_2u1,u2. The output neuron yy is a linear neuron, and we are using the squared error cost function.

Consider a single training case with target output tt. The sequence of computations required to compute the error (this is called forward

propagation) are as follows:

z1=z2=h1=h2=y=E=w1x1+w2x2w3x2+w4x3σ(z1)σ(z2)u1h1+u2h212(ty)2

EE is the error. Reminder: \sigma(x) = \frac{1}{1+\exp (-x)}σ(x)=1+exp(x)1

z_1z1 and z_2z2 are called the total inputs to hidden units h_1h1 and h_2h2 respectively.

Suppose we now decide to tie the weights so that w_2=w_3=w_{\text{tied}}w2=w3=wtied. What is the derivative of the error EE with respect to

w_{\text{tied}}wtied?

Hint: forget about weight tying for a moment and simply compute the derivatives \frac{\partial E}{\partial w_2}w2Eand \frac{\partial E}{\partial w_3}w3E.

Now set \frac{\partial E}{\partial w_{\text{tied}}}=\frac{\partial E}{\partial w_2}+\frac{\partial E}{\partial w_3}wtiedE=w2E+w3E.

\frac{\partial E}{\partial w_\text{tied}} = -2(t-y)(u_2 h_2(1-h_2)x_2)wtiedE=2(ty)(u2h2(1h2)x2)

\frac{\partial E}{\partial w_\text{tied}} = -2(t-y)(u_1 h_1(1-h_1)x_2)wtiedE=2(ty)(u1h1(1h1)x2)

\frac{\partial E}{\partial w_\text{tied}} = -(t-y)[u_1 h_1(1-h_1) + u_2 h_2(1-h_2)]x_2wtiedE=(ty)[u1h1(1h1)+u2h2(1h2)]x2

第 6 个问题

6. 第 6 个问题

Oh no! Brian's done it again! Claire had a dataset of 28 x 28 pixel handwritten digits nicely prepared to train a neural network, but Brian has gone and accidentally scrambled the images by re-ordering the pixels in some totally meaningless way, and now they can't get the original dataset back! Below is an image of a handwritten '2' before and after being scrambled by Brian.

BeforeAfter

Luckily, all of the images (in both the training set and the test set) were changed in the same way. For example, if pixels number 1 and number 3 switched places in one image, then they switched places in every other image as well. Because of that, Claire thinks that perhaps she can train a network after all.

Whether Claire is right or not depends largely on the type of neural network that she has in mind. Which of the following neural networks will be at a disadvantage because of Brian's mistake? Check all that apply.

猜你喜欢

转载自blog.csdn.net/SophieCXT/article/details/80866417