Shollow Neural Network 연습문제

post-thumbnail

Problem 3.1 What kind of mapping from input to output would be created if the activation function in equation 3.1 was linear so that a[z]=ψ0+ψ1z?a[z] = \psi_0 + \psi_1 z? What kind of mapping would be created if the activation function was removed, so a[z]=z?a[z] = z?

equation 3.1:

선형 활성화 함수를 쓰거나 활성화 함수를 제거하면, 신경망 전체는 결국 y = A + Bx 형태의 affine mapping이 되어 비선형 함수를 표현할 수 없다.

Problem 3.2 For each of the four linear regions in figure 3.3j, indicate which hidden units are inactive and which are active (i.e., which do and do not clip their inputs).

  • Region 1:
    h1 inactive, h2 inactive, h3 active
  • Region 2:
    h1 active, h2 inactive, h3 active
  • Region 3:
    h1 active, h2 active, h3 active
  • Region 4:
    h1 active, h2 active, h3 inactive

Problem 3.3 Derive expressions for the positions of the "joints" in fuction in figure 3.3j in terms of the ten parameters ϕ\phi and the input xx. Derive expressions for the slopes of the four linear regions.

x=θ10θ11,x=θ20θ21,x=θ30θ31x = -\frac{\theta_{10}}{\theta_{11}}, \quad x = -\frac{\theta_{20}}{\theta_{21}}, \quad x = -\frac{\theta_{30}}{\theta_{31}}

Problem 3.4 Draw a version of figure 3.3 where the y-intercept and slope of the third hidden unit have changed as in figure 3.14c. Assume that the remaining parameters remain the same.

figure 3.3 :

figure 3.14c :

Problem 3.5 Prove that the following property holds for αR+:\alpha \in \mathbb{R}^+:

ReLU[αz]=αReLU[z]\text{ReLU}[\alpha \cdot z] = \alpha \cdot \text{ReLU}[z]

This is known as the non-negative homogeneity property of the ReLU function.

ReLU(z)=max(0,z)라 하자.
(1) z ≥ 0 이면 ReLU(z)=z 이고, α>0 이므로 αz ≥ 0 이다.
따라서 ReLU(αz)=αz=αReLU(z).
(2) z < 0 이면 ReLU(z)=0 이고, α>0 이므로 αz < 0 이다.
따라서 ReLU(αz)=0=αReLU(z).
따라서 모든 α ∈ R^+에 대하여
ReLU(αz)=αReLU(z)
가 성립한다.

Problem 3.6 Following on from problem 3.5, what happens to the shallow network defined in equations 3.3 and 3.4 when we multiply the parameters θ10\theta_{10} and θ11\theta_{11} by a positive constant α\alpha and divide the slope ϕ1\phi_{1} by the same parameter α\alpha? What happens if α\alpha is negative?

equation 3.3 :

equation 3.4 :

α가 양수일 때는 출력 y가 변하지 않는다.
원래 첫 번째 hidden unit의 항은
φ1 ReLU(θ10 + θ11x)
이다.
여기서 θ10, θ11을 α배 하고, φ1을 1/α배 하면
(φ1/α) ReLU(αθ10 + αθ11x)
= (φ1/α) ReLU(α(θ10 + θ11x))
가 된다.
α > 0 이므로 ReLU의 성질
ReLU(αz) = α ReLU(z)
를 적용할 수 있다. 따라서
(φ1/α) ReLU(α(θ10 + θ11x))
= (φ1/α) · α ReLU(θ10 + θ11x)
= φ1 ReLU(θ10 + θ11x)
가 되어 원래와 같아진다.
즉 첫 번째 hidden unit의 출력 기여가 그대로이므로 전체 네트워크의 출력 y도 변하지 않는다.
반면 α가 음수이면
ReLU(αz) = α ReLU(z)
가 성립하지 않으므로 같은 방식으로 상쇄되지 않는다.
따라서 α < 0 인 경우에는 일반적으로 출력 y가 변한다.

Problem 3.7 Consider fitting the model in equation 3.1 using a least squares loss function. Does this loss function have a unique minimum? i.e., is there a single "best" set of parameters?

equation 3.1:

least squares loss는 일반적으로 unique minimum을 가지지 않는다.
즉, 하나의 “best” parameter set만 존재하는 것이 아니라,
같은 출력을 만드는 여러 다른 parameter 조합이 존재할 수 있다.
특히 ReLU network에서는 한 hidden unit의 내부 파라미터를 양수 α배 하고,
바깥 가중치를 1/α배 하면 전체 출력은 그대로 유지된다.
따라서 서로 다른 parameter set들이 정확히 같은 함수와 같은 loss 값을 만들 수 있다.
즉, 최소 loss를 주는 해가 여러 개 존재할 수 있으므로
이 loss function의 minimum은 일반적으로 unique하지 않다.

Problem 3.8 Consider replacing the ReLU activation function with (i) the Heaviside step function heaviside[z]\text{heaviside}[z], (ii) the hyperbolic tangent function tanh[z]\tanh[z], and (iii) the rectangular function rect[z]\text{rect}[z], where:

heaviside[z]={0z<01z0rect[z]={0z<010z10z>1(3.15)\text{heaviside}[z] = \begin{cases} 0 & z < 0 \\ 1 & z \geq 0 \end{cases} \quad \text{rect}[z] = \begin{cases} 0 & z < 0 \\ 1 & 0 \leq z \leq 1 \\ 0 & z > 1 \end{cases} \qquad (3.15)

Redraw a version of figure 3.3 for each of these functions. The original parameters were: ϕ={ϕ0,ϕ1,ϕ2,ϕ3,θ10,θ11,θ20,θ21,θ30,θ31}={0.23,1.3,1.3,0.66,0.2,0.4,0.9,0.9,1.1,0.7}\phi = \{\phi_0, \phi_1, \phi_2, \phi_3, \theta_{10}, \theta_{11}, \theta_{20}, \theta_{21}, \theta_{30}, \theta_{31}\} = \{-0.23, -1.3, 1.3, 0.66, -0.2, 0.4, -0.9, 0.9, 1.1, -0.7\}. Provide an informal description of the family of functions that can be created by neural networks with one input, three hidden units, and one output for each activation function.

Problem 3.9 Show that the third linear region in figure 3.3 has a slope that is the sum of the slopes of the first and fourth linear regions.

figure 3.3 :

Problem 3.10 Consider a neural network with one input, one output, and three hidden units. The construction in figure 3.3 shows how this creates four linear regions. Under what circumstances could this network produce a function with fewer than four linear regions?

figure 3.3 :

이 네트워크가 4개보다 적은 linear region을 만드는 경우는,
일부 hidden unit이 새로운 joint(꺾이는 점)를 만들지 못할 때이다.
예를 들어,
1. 어떤 hidden unit이 모든 x 구간에서 항상 inactive이거나 항상 active인 경우
→ 새로운 꺾이는 점을 만들지 못한다.
2. 두 hidden unit의 joint가 같은 x 위치에서 겹치는 경우
→ 원래 두 번 꺾여야 할 것이 한 번만 꺾인다.
3. 어떤 hidden unit이 활성화되거나 비활성화되는 지점에서
전체 기울기가 실제로 변하지 않는 경우
(예: 해당 unit의 출력 가중치가 0이거나, 다른 unit의 변화와 상쇄되는 경우)
→ 그래프상 새로운 linear region이 생기지 않는다.
따라서 hidden unit이 실제로 distinct한 slope change를 만들지 못하면,
이 네트워크는 4개보다 적은 linear region을 가진 함수를 만들 수 있다.

Problem 3.11 How many parameters does the model in figure 3.6 have?

18개

Problem 3.12 How many parameters does the model in figure 3.7 have?

13개

Problem 3.13 What is the activation pattern for each of the seven regions in figure 3.8j? In other words, which hidden units are active (pass the input) and which are inactive (clip the input) for each region?

figure 3.8 :

  1. 왼쪽 아래 영역: (inactive,inactive,active)(\text{inactive}, \text{inactive}, \text{active})
  2. 왼쪽 가운데 쐐기 영역: (inactive,inactive,inactive)(\text{inactive}, \text{inactive}, \text{inactive})
  3. 왼쪽 위 영역: (active,inactive,inactive)(\text{active}, \text{inactive}, \text{inactive})
  4. 가운데 영역: (active,inactive,active)(\text{active}, \text{inactive}, \text{active})
  5. 오른쪽 아래 작은 영역: (inactive,active,active)(\text{inactive}, \text{active}, \text{active})
  6. 오른쪽 가운데 영역: (active,active,active)(\text{active}, \text{active}, \text{active})
  7. 오른쪽 위 영역: (active,active,inactive)(\text{active}, \text{active}, \text{inactive})

Problem 3.14 Write out the equations that define the network in figure 3.11. There should be three equations to compute the three hidden units from the inputs and two equations to compute the outputs from the hidden units.

figure 3.11 :

h1=a(θ10+θ11x1+θ12x2+θ13x3)h_1 = a(\theta_{10} + \theta_{11}x_1 + \theta_{12}x_2 + \theta_{13}x_3)
h2=a(θ20+θ21x1+θ22x2+θ23x3)h_2 = a(\theta_{20} + \theta_{21}x_1 + \theta_{22}x_2 + \theta_{23}x_3)
h3=a(θ30+θ31x1+θ32x2+θ33x3)h_3 = a(\theta_{30} + \theta_{31}x_1 + \theta_{32}x_2 + \theta_{33}x_3)
y1=θ40+θ41h1+θ42h2+θ43h3y_1 = \theta_{40} + \theta_{41}h_1 + \theta_{42}h_2 + \theta_{43}h_3
y2=θ50+θ51h1+θ52h2+θ53h3y_2 = \theta_{50} + \theta_{51}h_1 + \theta_{52}h_2 + \theta_{53}h_3

Problem 3.15 What is the maximum possible number of 3D linear regions that can be created by the network in figure 3.11?

figure 3.11 :

8개 (nC0 + nC1 + nC2 + nC3) , n 은 hidden unit의 개수

Problem 3.16 Write out the equations for a shallow network with two inputs, four hidden units, and three outputs. Draw this model in the style of figure 3.11.

figure 3.11 :

Problem 3.17 Equations 3.11 and 3.12 define a general neural network with DiD_i inputs, one hidden layer containing DD hidden units, and DoD_o outputs. Find an expression for the number of parameters in the model in terms of DiD_i, DD, and DoD_o.

equation 3.11 :

equation 3.12 :

파라미터 개수 : D(Di+1)+Do(D+1)D(D_i + 1) + D_o(D + 1)

Problem 3.18 Show that the maximum number of regions created by a shallow network with Di=2D_i = 2-dimensional input, Do=1D_o = 1-dimensional output, and D=3D = 3 hidden units is seven, as in figure 3.8j. Use the result of Zaslavsky (1975) that the maximum number of regions created by partitioning a DiD_i-dimensional space with DD hyperplanes is j=0Di(Dj)\sum_{j=0}^{D_i} \binom{D}{j}. What is the maximum number of regions if we add two more hidden units to this model, so D=5D = 5?

주어진 결과에 따르면, DiD_i차원 공간을 DD개의 hyperplane으로 나눌 때 만들 수 있는 최대 영역 수는

j=0Di(Dj)\sum_{j=0}^{D_i} \binom{D}{j}

이다.


1. Di=2D_i = 2, D=3D = 3인 경우

입력 차원이 2차원이므로,

j=02(3j)=(30)+(31)+(32)\sum_{j=0}^{2} \binom{3}{j} = \binom{3}{0} + \binom{3}{1} + \binom{3}{2}

각 항을 계산하면

=1+3+3=7= 1 + 3 + 3 = 7

따라서, hidden unit이 3개인 shallow network가 만들 수 있는 최대 영역 수는

77

이다.

즉, figure 3.8j의 7개 영역과 일치한다.


2. hidden unit을 2개 더 추가해서 D=5D = 5인 경우

이제 Di=2D_i = 2, D=5D = 5이므로,

j=02(5j)=(50)+(51)+(52)\sum_{j=0}^{2} \binom{5}{j} = \binom{5}{0} + \binom{5}{1} + \binom{5}{2}

계산하면

=1+5+10=16= 1 + 5 + 10 = 16

따라서 hidden unit이 5개일 때 만들 수 있는 최대 영역 수는

1616

이다.


최종 답

  • Di=2D_i = 2, D=3D = 3일 때 최대 영역 수: 77
  • Di=2D_i = 2, D=5D = 5일 때 최대 영역 수: 1616

0개의 댓글