IT story

신경망의 가중치를 난수로 초기화해야하는 이유는 무엇입니까?

hot-time 2020. 9. 2. 20:46
반응형

신경망의 가중치를 난수로 초기화해야하는 이유는 무엇입니까?


신경망을 처음부터 구축하려고합니다. 모든 AI 문헌에는 네트워크가 더 빨리 수렴하기 위해 가중치를 임의의 숫자로 초기화해야한다는 합의가 있습니다.

그러나 신경망 초기 가중치가 난수로 초기화되는 이유는 무엇입니까?

나는 어딘가에서 이것이 "대칭을 깨뜨리기"위해 행해지는 것을 읽었고 이것은 신경망이 더 빨리 학습하게 만든다. 대칭을 깨면 어떻게 더 빨리 학습 할 수 있습니까?

가중치를 0으로 초기화하는 것이 더 나은 생각이 아닐까요? 그러면 가중치가 양수이든 음수이든 더 빨리 값을 찾을 수 있습니까?

가중치가 초기화 될 때 최적 값에 가까워지기를 바라는 것 외에 가중치를 무작위 화하는 뒤에 다른 기본 철학이 있습니까?


여기서 대칭을 깨는 것은 필수적이지 성능의 이유가 아닙니다. 다중 레이어 퍼셉트론의 처음 2 개 레이어 (입력 레이어와 은닉 레이어)를 상상해보십시오.

여기에 이미지 설명 입력

순방향 전파 중에 은닉층의 각 유닛은 신호를받습니다.

여기에 이미지 설명 입력

즉, 각 은닉 유닛은 입력 합계에 해당 가중치를 곱합니다.

이제 모든 가중치를 동일한 값 (예 : 0 또는 1)으로 초기화한다고 가정합니다. 이 경우 각 은닉 유닛은 정확히 동일한 신호를 받습니다. 예를 들어 모든 가중치가 1로 초기화되면 각 단위는 입력 (및 출력 sigmoid(sum(inputs)))의 합계와 동일한 신호를받습니다 . 모든 가중치가 0이면 더 나쁜 경우 모든 숨겨진 유닛은 0 신호를 받게됩니다. 입력이 무엇이든 상관없이-모든 가중치가 동일하면 히든 레이어의 모든 단위도 동일 합니다.

이것은 대칭의 주요 문제이며 가중치를 무작위로 (또는 적어도 다른 값으로) 초기화해야하는 이유입니다. 이 문제는 각 연결을 사용하는 모든 아키텍처에 영향을 미칩니다.


유추:

나는 그것이 좋은 비유가되기를 바랍니다. 가능한 한 간단하게 설명하려고 노력했습니다.

누군가가 당신을 헬리콥터에서 알려지지 않은 산 정상으로 떨어 뜨 렸고 거기에 갇혀 있다고 상상해보십시오. 사방이 흐려집니다. 당신이 아는 유일한 것은 당신이 어떻게 든 해수면으로 내려 가야한다는 것입니다. 가능한 가장 낮은 지점으로 내려 가려면 어느 방향으로 가야합니까?

해수면으로가는 길을 찾을 수 없어서 헬리콥터가 다시 당신을 데려 가서 같은 산 정상 위치로 떨어 뜨릴 것입니다. 동일한 시작 위치로 자신을 "초기화"하고 있기 때문에 동일한 방향을 다시 취해야합니다 .

그러나 헬리콥터 가 산의 어딘가에 무작위로 떨어질 때마다 다른 방향과 단계를 밟게됩니다. 따라서 가능한 가장 낮은 지점에 도달 할 수있는 더 좋은 기회 가있을 것 입니다.

이것이 대칭깨뜨리는 것 입니다. 초기화는 비대칭 ( 다름 )이므로 동일한 문제에 대한 다른 솔루션을 찾을 수 있습니다.

이 비유 에서 당신이 착륙하는 곳은 가중치 입니다. 따라서 가중치가 다르면 가장 낮은 ( 또는 더 낮은 ) 지점 에 도달 할 가능성이 더 높습니다 .

또한 시스템 엔트로피증가시켜 시스템이 더 낮은 지점을 찾는 데 도움이되는 더 많은 정보를 생성 할 수 있습니다 ( 로컬 또는 글로벌 최소값 ).

여기에 이미지 설명 입력


대답은 아주 간단합니다. 기본 훈련 알고리즘은 본질적으로 탐욕 스럽습니다. 그들은 글로벌 최적을 찾지 못하고 오히려 "가장 가까운"로컬 솔루션을 찾습니다. 결과적으로 고정 된 초기화에서 시작하면 솔루션이 특정 가중치 집합으로 편향됩니다. 무작위로 (그리고 아마도 여러 번) 수행하면 오류 표면의 이상한 부분에 갇힐 가능성이 훨씬 적습니다.

The same argument applies to other algorithms, which are not able to find a global optimum (k-means, EM, etc.) and does not apply to the global optimization techniques (like SMO algorithm for SVM).


As you mentioned, the key point is breaking the symmetry. Because if you initialize all weights to zero then all of the hidden neurons(units) in your neural network will be doing the exact same calculations. This is not something we desire because we want different hidden units to compute different functions. However, this is not possible if you initialize all to the same value.


In addition to initialization with random values, initial weights should not start with large values. This is because we often use the tanh and sigmoid functions in hidden layers and output layers. If you look at the graphs of the two functions, after forward propagation at the first iteration results in higher values, and these values correspond to the places in the sigmoid and tanh functions that converge the derivative to zero. This leads to a cold start of the learning process and an increase in learning time. As a result, if you start weights at random, you can avoid these problems by multiplying these values by values such as "0.01" or "0.001".


  1. Wouldn't initializing the weights to 0 be a better idea? That way the weights would be able to find their values (whether positive or negative) faster?

  2. How does breaking the symmetry make it learn faster?

If you initialize all the weights to be zero, then all the the neurons of all the layers performs the same calculation, giving the same output and there by making the whole deep net useless. If the weights are zero, complexity of the whole deep net would be the same as that of a single neuron and the predictions would be nothing better than random.

Nodes that are side-by-side in a hidden layer connected to the same inputs must have different weights for the learning algorithm to update the weights.

By making weights as non zero ( but close to 0 like 0.1 etc), the algorithm will learn the weights in next iterations and won't be stuck. In this way, breaking the symmetry happens.

  1. Is there some other underlying philosophy behind randomizing the weights apart from hoping that they would be near their optimum values when initialized?

Stochastic optimization algorithms such as stochastic gradient descent use randomness in selecting a starting point for the search and in the progression of the search.

The progression of the search or learning of a neural network is known as convergence. Discovering a sub-optimal solution or local optima result into premature convergence.

Instead of relying on one local optima, if you run your algorithm multiple times with different random weights, there is a best possibility of finding global optima without getting stuck at local optima.

2015 년 이후, 기계 학습 연구의 발전으로 인해 He-et-al Initializatio n이 도입되어 무작위 초기화 를 대체합니다.

w=np.random.randn(layer_size[l],layer_size[l-1])*np.sqrt(2/layer_size[l-1])

가중치는 여전히 무작위이지만 이전 뉴런 계층의 크기에 따라 범위가 다릅니다.

요약하면, 0이 아닌 임의 가중치는

  1. 지역 옵티마에서 나오십시오
  2. 대칭성 깨기
  3. 추가 반복에서 글로벌 최적화에 도달

참고 문헌 :

머신 러닝 마스터리

데이터 과학을 향해

참고 URL : https://stackoverflow.com/questions/20027598/why-should-weights-of-neural-networks-be-initialized-to-random-numbers

반응형