brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Dec 18. 2020

앤드류 응의 머신러닝(17-6):맵 축소 및 병렬 처리

   온라인 강의 플랫폼 코세라의 창립자인 앤드류 응 (Andrew Ng) 교수는 인공지능 업계의 거장입니다. 그가 스탠퍼드 대학에서 머신 러닝 입문자에게 한 강의를 그대로 코세라 온라인 강의 (Coursera.org)에서 무료로 배울 수 있습니다. 이 강의는 머신러닝 입문자들의 필수코스입니다. 인공지능과 머신러닝을 혼자 공부하면서 자연스럽게 만나게 되는 강의입니다. 



Large Scale Machine Learning   

(대규모 머신러닝)


Advanced Topic  (고급 주제)      


Map Reduce and Data Parallelism (맵 축소 및 데이터 병렬화)   



   In the last few videos, we talked about stochastic gradient descent, and, you know, other variations of the stochastic gradient descent algorithm, including those adaptations to online learning, but all of those algorithms could be run on one machine, or could be run on one computer. And some machine learning problems are just too big to run on one machine, sometimes maybe you just so much data you just don't ever want to run all that data through a single computer, no matter what algorithm you would use on that computer. So in this video I'd like to talk about different approach to large scale machine learning, called the map reduce approach. And even though we have quite a few videos on stochastic gradient descent and we're going to spend relative less time on map reduce--don't judge the relative importance of map reduce versus the gradient descent based on the amount amount of time I spend on these ideas in particular. Many people will say that map reduce is at least an equally important, and some would say an even more important idea compared to gradient descent, only it's relatively simpler to explain, which is why I'm going to spend less time on it, but using these ideas you might be able to scale learning algorithms to even far larger problems than is possible using stochastic gradient descent.


   지난 몇 개의 강의에서 우리는 확률적 경사 하강법과 온라인 학습 알고리즘을 다루었습니다. 실제로 모든 알고리즘은 하나의 기계 또는 하나의 서버에서 실행할 수 있지만, 일부 머신 러닝 문제는 하나의 기계나 서버만 실행하기에 너무 크거나 데이터 학습 셋이 너무 큽니다. 그래서, 하나의 서버에서 처리하지 않고 여러 대의 서버에서 데이터를 처리합니다. 따라서, 이번 강의에서 대규모 머신러닝에 대한 다른 접근 방법인 맵 축소 접근법을 설명합니다. 확률적 경사 하강법은 여러 강의에서 설명했지만, 맵 축소 접근법은 이번 강의에서만 설명합니다. 강의 시간을 기준으로 맵 축소 접근법이 확률적 경사 하강법이 더 중요하지 않다고 판단하지 마세요. 많은 사람들이 맵 축소는 확률적 경사 하강법만큼 중요하다고 말했고, 어떤 사람들은 확률적 경사 하강법보다 훨씬 더 중요한 아이디어라고 말합니다. 단지 설명하기가 상대적으로 더 간단할 뿐입니다. 맵 축소 접근법은 확률적 경사 하강법이 처리할 수 있는 것보다 훨씬 더 큰 머신러닝 문제를 다를 수 있습니다.



   Here's the idea. Let's say we want to fit a linear regression model or a logistic regression model or some such, and let's start again with batch gradient descent, so that's our batch gradient descent learning rule. And to keep the writing on this slide tractable, I'm going to assume throughout that we have m equals 400 examples. Of course, by our standards, in terms of large scale machine learning, you know m might be pretty small and so, this might be more commonly applied to problems, where you have maybe closer to 400 million examples, or some such, but just to make the writing on the slide simpler, I'm going to pretend we have 400 examples. So in that case, the batch gradient descent learning rule has this 400 and the sum from i equals 1 through 400 through my 400 examples here, and if m is large, then this is a computationally expensive step. So, what the MapReduce idea does is the following, and I should say the map reduce idea is due to two researchers, Jeff Dean and Sanjay Gimawat. Jeff Dean, by the way, is one of the most legendary engineers in all of Silicon Valley and he kind of built a large fraction of the architectural infrastructure that all of Google runs on today. 


   여기 맵 축소 접근법이 있습니다. 선형 회귀 모델이나 로지스틱 회귀 모델에 배치 경사 하강법을 적용한다고 가정합니다. 여기 배치 경사 하강법 업데이트 규칙이 있습니다.


                                                     m

               θj := θj - α *1/m *Σ (hθ(x^(i)) - y^(i))*xj^(i) 

                                                     i=1

                         (for j = 0,1,..., n)


   대형 머신 러닝 측면에서 m은 매우 작을 수 있고 4억 개에 가까울 수도 있습니다. 여기서 설명하기 쉽게 400 개의 예제가 있다고 가정합니다. 이때 배치 경사 하강법 업데이 규칙에 예제 합산은 i=1에서 m = 400까지입니다. m이 클수록 연산 비용이 높습니다. 여기서 맵 축소 접근법 아이디어를 활용합니다. 맵 축소 아이디어는 두 명의 연구원 제프 딘(Jeff Dean)과 산제이 기마왓 (Sanjay Gimawat)이 만들었습니다. 제프 딘은 실리콘 밸리에서 가장 전설적인 엔지니어 중 한 명이며 현재 구글이 운영하는 대부분의 아키택처 인프라를 구축했습니다.



   But here's the map reduce idea. So, let's say I have some training set, if we want to denote by this box here of X Y pairs, where it's X1, Y1, down to my 400 examples, Xm, Ym. So, that's my training set with 400 training examples. In the MapReduce idea, one way to do, is split this training set in to different subsets. I'm going to assume for this example that I have 4 computers, or 4 machines to run in parallel on my training set, which is why I'm splitting this into 4 machines. If you have 10 machines or 100 machines, then you would split your training set into 10 pieces or 100 pieces or what have you. And what the first of my 4 machines is to do, say, is use just the first one quarter of my training set--so use just the first 100 training examples. And in particular, what it's going to do is look at this summation, and compute that summation for just the first 100 training examples. So let me write that up I'm going to compute a variable temp 1 to superscript 1 the first machine J equals sum from equals 1 through 100, and then I'm going to plug in exactly that term there--so I have X-theta, Xi, minus Yi times Xij, right? So that's just that gradient descent term up there.


   맵 축소 아이디어의 동작 방식은 다음과 같습니다. 여기 (x, y) 쌍의 학습 셋이 있습니다. (x^(1), y^(1)), (x^(2), y^(2),..., (x^(m), y^(m))까지 400개의 학습 예제가 있는 학습 셋입니다. 맵 축소 아이디어는 학습 셋을 여러 개의 하위 셋으로 분할합니다.  4 대 서버에서 4개로 분할된 하위 셋을 각각 병렬로 실행할 것입니다. 서버가 10 대 또는 100 대일 경우에 학습 셋을 10 개 또는 100개로 분할합니다. 첫 번째 서버는 4개로 분할한 학습 셋 중 첫 번째 학습 셋을 사용합니다. 첫 100개의 학습 예제만 사용합니다. 경사 하강 업데이트의 합산 Σ 부분을 계산하고 temp^(1)이라고 표시합니다. 


    첫 번째 분할 학습 셋 : (x^(1), y^(1)), (x^(2), y^(2),..., (x^(100), y^(100))


                                      100

              temp^(1)j = Σ(hθ(x^(i)) - y^(i))*xj^(i) 

                                        i=1

                     

   첫 번째 서버는 비용 함수 J를 1부터 100까지 예제를 합산합니다. 

   


 And then similarly, I'm going to take the second quarter of my data and send it to my second machine, and my second machine will use training examples 101 through 200 and you will compute similar variables of a temp to j which is the same sum for index from examples 101 through 200. 


   비슷하게 두 번째 서버는 두 번째 분할된 학습 셋을 계산합니다. 


   두 번째 분할 학습 셋 : (x^(101), y^(101)), (x^(102), y^(102),..., (x^(200), y^(200))


                                      200

              temp^(2)j = Σ(hθ(x^(i)) - y^(i))*xj^(i) 

                                        i=1

                     

   두 번째 서버는 비용 함수 J를 101부터 200까지 예제를 합산합니다. 

   



And similarly machines 3 and 4 will use the third quarter and the fourth quarter of my training set. So now each machine has to sum over 100 instead of over 400 examples and so has to do only a quarter of the work and thus presumably it could do it about four times as fast.


   세 번째 분할 학습 셋 : (x^(201), y^(201)), (x^(202), y^(202),..., (x^(300), y^(300))


                                      200

              temp^(3)j = Σ(hθ(x^(i)) - y^(i))*xj^(i) 

                                        i=1

                     

   세 번째 서버는 비용 함수 J를 201부터 300까지 예제를 합산합니다. 


   네 번째 분할 학습 셋 : (x^(301), y^(301)), (x^(302), y^(302),..., (x^(400), y^(400))


                                      200

              temp^(4)j = Σ(hθ(x^(i)) - y^(i))*xj^(i) 

                                        i=1

                     

   네 번째 서버는 비용 함수 J를 301부터 400까지 예제를 합산합니다. 



   Finally, after all these machines have done this work, I am going to take these temp variables and put them back together. So I take these variables and send them all to a You know centralized master server and what the master will do is combine these results together and in particular, it will update my parameters theta j according to theta j gets updated as theta j minus Of the learning rate alpha times one over 400 times temp, 1, J, plus temp 2j plus temp 3j plus temp 4j and of course we have to do this separately for J equals 0. You know, up to and within this number of features. So operating this equation into I hope it's clear. So what this equation is doing is exactly the same is that when you have a centralized master server that takes the results, the temp^(1) j, temp^(2) j, temp^(3) j, temp^(4) j and adds them up and so of course the sum of these four things.


   마지막으로 모든 서버가 작업을 완료한 후 temp 변수의 값을 업데이트합니다. 중앙 집중식 마스터 서버는 4개 temp 변수를 취합하여 하나로 결합합니다.   

                                                     

     θj := θj - α *1/400 *(temp^(1)j + temp^(2)j + temp^(3)j + temp^(4)j)                              

             (for j = 0,1,..., n)


   물론, 비용 함수 J = 0 인 경우에는 별도로 다루어야 합니다. 방정식을 계산하면 명확해질 것입니다. 이 방정식이 하는 일은  다음의 배치 경사 하강법 업데이트와 똑같습니다.  


                                                      400

               θj := θj - α *1/400 *Σ (hθ(x^(i)) - y^(i))*xj^(i) 

                                                        i=1

                       (for j = 0,1,..., n)


   두 개의 분홍색 박스는 동일한 방정식입니다. 



Right, that's just the sum of this, plus the sum of this, plus the sum of this, plus the sum of that, and those four things just add up to be equal to this sum that we're originally computing a batch stream descent. And then we have the alpha times 1 of 400, alpha times 1 of 100, and this is exactly equivalent to the batch gradient descent algorithm, only, instead of needing to sum over all four hundred training examples on just one machine, we can instead divide up the work load on four machines.


   temp^(1)j, temp^(2)j, temp^(3)j, temp^(4)j의  4개의 변수를 합한 것과 같습니다. 배치 경사 하강 업데이트의 1에서 400까지의 Σ 합산을 합친 것과 4개의 변수의 합은 동일합니다. 즉, 단 하나의 서버에서 400개의 학습 에제를 모두 합산할 필요가 없습니다. 4대의 서버로 작업을 분배할 수 있습니다. 



   So, here's what the general picture of the MapReduce technique looks like. We have some training sets.


   여기 맵 축소 기술을 도식화한 그림이 있습니다. 몇 개의 학습 셋이 있습니다.



   And if we want to parallelize across four machines, we are going to take the training set and split it, you know, equally. Split it as evenly as we can into four subsets. Then we are going to take the 4 subsets of the training data and send them to 4 different computers. And each of the 4 computers can compute a summation over just one quarter of the training set, and then finally take each of the computers takes the results, sends them to a centralized server, which then combines the results together. 


   4대의 서버로 병렬 처리를 하기 위해 학습 셋을 4개로 균등 분할합니다. 4개의 분할된 학습 셋을 4대의 서버로 전달합니다. 4대의 서버는 각각 4개의 분할된 학습 셋에 대한 합산을 완료한 후 중앙 서버로 결과를 전송합니다. 중앙 서버는 4개의 결과를 합산합니다. 


   So, on the previous slide in that example, the bulk of the work in gradient descent, was computing the sum from i equals 1 to 400 of something. So more generally, sum from i equals 1 to m of that formula for gradient descent. And now, because each of the four computers can do just a quarter of the work, potentially you can get up to a 4x speed up. In particular, if there were no network latencies and no costs of the network communications to send the data back and forth, you can potentially get up to a 4x speed up. Of course, in practice, because of network latencies, the overhead of combining the results afterwards and other factors, in practice you get slightly less than a 4x speedup. 


   이전 슬라이드에서 경사 하강법 연산을 학습 예제 i=1에서 400까지 계산하였습니다. 일반적인 공식으로 표현하면 i=1에서 m까지입니다. 4대의 서버가 각각 1/4씩 계산을 하였으므로 잠재적으로 최대 4배까지 성능을 향상할 수 있습니다. 네트워크 대기 시간이 없고 데이터를 주고받기 위한 통신 비용이 없다면, 잠재적으로 최대 4배까지 속도를 높일 수 있습니다. 실제로 네트워크 지연 시간, 결과를 합산하는 오버 헤드 및 기타 요인으로 인해 최대 4배 향상보다 약간 낮습니다. 



   But, none the less, this sort of Map Reduce approach does offer  us a way to process much larger data sets than is possible using a single computer. If you are thinking of applying Map Reduce to some learning algorithm, in order to speed this up. By paralleling the computation over different computers, the key question to ask yourself is, can your learning algorithm be expressed as a summation over the training set? And it turns out that many learning algorithms can actually be expressed as computing sums of functions over the training set and the computational expense of running them on large data sets is because they need to sum over a very large training set. So, whenever your learning algorithm can be expressed as a sum of the training set and whenever the bulk of the work of the learning algorithm can be expressed as the sum of the training set, then map reduce might a good candidate for scaling your learning algorithms through very, very good data sets.


   그럼에도 불구하고 맵 축소 접근법은 단 하나의 서버를 사용하는 것보다 훨씬 더 큰 데이터를 처리할 수 있는 방법을 제공합니다. 속도를 높이기 위해 일부 학습 알고리즘에 맵 축소 접근법을 적용할 생각이라면 스스로에게 질문해야 합니다. 학습 알고리즘은 학습 셋에 대한 함수의 합산으로 표현할 수 있나요? 많은 학습 알고리즘이 학습 셋에 대한 함수로 분할한 후 다시 함수를 합산할 수 있습니다. 대용량 데이터 셋에 대한 대부분의 연산 비용은 데이터 합산 때문에 발생합니다. 학습 알고리즘이 학습 셋의 함수에 대한 합산으로 표현할 수 있을 경우 맵 축소 접근법은 학습 셋을 확장할 수 있는 매우 좋은 접근법입니다. 



   Lets just look at one more example. Let's say that we want to use one of the advanced optimization algorithm. So, things like, you know, L-BFGS, Conjugate gradient and so on, and let's say we want to train a logistic regression of the algorithm. For that, we need to compute two main quantities. One is for the advanced optimization algorithms like, you know, L-BFGS and Conjugate gradient. We need to provide it a routine to compute the cost function of the optimization objective. And so for logistic regression, you remember that a cost function has this sort of sum over the training set, and so if youre paralizing over ten machines, you would split up the training set onto ten machines and have each of the ten machines compute the sum of this quantity over just one tenth of the training data. Then, the other thing that the advanced optimization algorithms need, is a routine to compute these partial derivative terms. Once again, these derivative terms, for which it's a logistic regression, can be expressed as a sum over the training set, and so once again, similar to our earlier example, you would have each machine compute that summation over just some small fraction of your training data. And finally, having computed all of these things, they could then send their results to a centralized server, which can then add up the partial sums. This corresponds to adding up those tenth i or tenth ij variables, which were computed locally on machine number i, and so the centralized server can sum these things up and get the overall cost function and get the overall partial derivative, which you can then pass through the advanced optimization algorithm.


   예를 하나 더 살펴봅니다. L-BFGS 또는 Conjugate gradient과 같은 고급 최적화 알고리즘 중 하나를 사용한다고 가정합니다. 고급 최적화 알고리즘을 활용하여 로지스틱 회귀 알고리즘을 학습시킵니다.  먼저 두 가지를 계산해야 합니다. 하나는 L-BFGS 또는 Conjugate gradient와 같은 고급 최적화 알고리즘입니다. 최적화 목표를 위한 비용 함수를 계산하는 순서를 제공해야 합니다. 그리고 로지스틱 회귀는 비용 함수는 학습 셋의 합산이 있습니다. 그리고 10대의 서버로 병렬 처리를 하기 위해 학습 셋을 10개로 분할합니다. 각 서버는 1/10 개의 학습 셋을 계산합니다. 고급 최적화 알고리즘은 편미분항을 계산하는 절차가 필요합니다. 미분항들은 학습 셋의 합산으로 표현될 수 있습니다. 각 서버들은 분할된 학습 셋에 대한 합산을 계산합니다. 마지막으로 각 서버는 계산 결과를 중앙 집중식 서버로 전달하고, 중앙 집중식 서버는 부분 합계를 합산합니다. 1번 서버가 계산한 부분 합계는 temp^(1)이고, i번째 서버가 계산한 부분 합계는  temp^(i) j입니다. 이렇게 중앙 집중식 서버는 고급 최적화 알고리즘을 통해 전체 비용 함수와 전체 편미분의 값을 얻을 수 있습니다.  


   So, more broadly, by taking other learning algorithms and expressing them in sort of summation form or by expressing them in terms of computing sums of functions over the training set, you can use the MapReduce technique to parallelize other learning algorithms as well, and scale them to very large training sets.


   따라서 보다 광범위하게 다른 학습 알고리즘을 이용하여 합산하거나 학습 셋에 대한 함수를 합산하는 방법을 제공하는 맵 축소 접근법은  병렬 처리를 가능하게 하고 아주 큰 학습 셋으로 확장할 수 있게 합니다. 



   Finally, as one last comment, so far we have been discussing MapReduce algorithms as allowing you to parallelize over multiple computers, maybe multiple computers in a computer cluster or over multiple computers in the data center. It turns out that sometimes even if you have just a single computer, MapReduce can also be applicable. In particular, on many single computers now, you can have multiple processing cores. You can have multiple CPUs, and within each CPU you can have multiple proc cores. If you have a large trainingset, what you can do if, say, you have a computer with 4 computing cores, what you can do is, even on a single computer you can split the training sets into pieces and send the training set to different cores within a single box, like within a single desktop computer or a single server and use MapReduce this way to divvy up work load. Each of the cores can then carry out the sum over, say, one quarter of your training set, and then they can take the partial sums and combine them, in order to get the summation over the entire training set. The advantage of thinking about MapReduce this way, as paralleilyzing over cores within a single machine, rather than parallelizing over multiple machines is that, this way you don't have to worry about network latency, because all the communication, all the sending of the [xx] back and forth, all that happens within a single machine. And so network latency becomes much less of an issue compared to if you were using this to over different computers within the data sensor. 


   마지막으로 한 가지 코멘트를 달겠습니다. 지금까지 맵 축소 알고리즘은 서버 클러스터의 서버 또는 데이터 센터의 여러 서버를 병렬로 처리할 수 있다고 설명했습니다. 때때로 서버 한 대라도 맵 축소 알고리즘을 적용할 수 있습니다. 현재 많은 서버들은 한 서버가 여러 개의 CPU를 장착하거나 하나의 CPU가 여러 개의 코어를 장착할 수 있습니다. 예를 들어, 4 개의 코어가 있는 서버는 대규모 학습 셋을 여러 조작으로 분할하고 각각의 코어로 분할된 학습 셋을 전달합니다. 하나의 PC 또는 하나의 서버는 여러 개의 코어를 가지고 맵 축소 접근법을 사용하여 CPU 부하를 분산합니다. 4개의 코어를 가진 서버는 학습 셋의 4개로 분할하고 각 코어는 1/4의 합계를 계산합니다. 중앙 서버는 부분 합계를 코어로부터 수신하여 전체 학습 셋에 대한 합계를 계산합니다. 맵 축소 기술의 장점은 여러 시스템에서 병렬화하는 것이 아니나 단일 서버 내에서 코어를 병렬화하기 때문에 네트워크 지연을 걱정할 필요가 없습니다. 모든 통신, 모든 송수신이 한 시스템에서 발생합니다. 네트워크 대기 시간은 데이터 센터 내의 다른 서버들을 활용하는 것보다 훨씬 적게 필요합니다. 


   Finally, one last caveat on parallelizing within a multi-core machine. Depending on the details of your implementation, if you have a multi-core machine and if you have certain numerical linear algebra libraries. It turns out that the sum numerical linear algebra libraries that can automatically parallelize their linear algebra operations across multiple cores within the machine. So if you're fortunate enough to be using one of those numerical linear algebra libraries and certainly this does not apply to every single library. If you're using one of those libraries and. If you have a very good vectorizing implementation of the learning algorithm. Sometimes you can just implement you standard learning algorithm in a vectorized fashion and not worry about parallelization and numerical linear algebra libararies could take care of some of it for you. So you don't need to implement it but. for other any problems, taking advantage of this sort of map reducing commentation, finding and using this MapReduce formulation and to paralelize a cross cores except yourself might be a good idea as well and could let you speed up your learning algorithm.


   마지막으로 멀티 코어 서버 내에서 병렬 처리를 하는 것에 대한 마지막 주의 사항입니다. 실제로 멀티 코어 서버가 있는지 또는 특정 선형 대수 라이브러리가 있는지에 따라 세부적인 구현 방식이 달라질 수 있습니다. 선형 대수 라이브러리 중 어떤 것들은 서버 내의 여러 코어에 걸쳐서 연산을 자동으로 병렬화합니다. 이런 선형 대수 라이브러리 중 하나를 사용한다면 병렬 처리를 시도할 필요가 없습니다. 또한, 학습 알고리즘의 벡터화 구현이 아주 좋은 경우에도 병렬 처리를 시도할 필요가 없습니다. 벡터화 구현이 아주 좋은 알고리즘은 선형 대수 라이브러리로 처리할 수 있습니다. 다른 경우에 맵 축소 알고리즘을 사용하여 여러 코어들을 병렬로 처리하는 것은 매우 좋은 생각이고 속도를 높일 수 있습니다. 

   

   In this video, we talked about the MapReduce approach to parallelizing machine learning by taking a data and spreading them across many computers in the data center. Although these ideas are critical to paralysing across multiple cores within a single computer as well. Today there are some good open source implementations of MapReduce,  so there are many users in open source system called Hadoop and using either your own implementation or using someone else's open source implementation, you can use these ideas to parallelize learning algorithms and get them to run on much larger data sets than is possible using just a single machine.


   이번 강의에서 데이터를 분할하여 데이터 센터의 많은 서버로 분산하여 학습 알고리즘을 병렬로 처리하는 맵 축소 접근법을 설명했습니다. 또한, 맵 축소 접근법은 단일 서버 내의 다수의 코어를 병렬로 처리할 수 있습니다. 오늘날 맵 축소 접근법의 좋은 오픈 소스 구현은 하둡(Hadoop)입니다.  하둡의 많은 사용자들은 직접 구현하거나 다른 사람들이 구현한 오픈 소스를 사용합니다. 하둡을 활 요하여 단일 서버를 사용하는 것보다 훨씬 더 큰 데이터 센터에서 학습 알고리즘을 병렬로 처리합니다.  


앤드류 응의 머신러닝 동영상 강의




정리하며


   모든 알고리즘은 하나의 기계 또는 하나의 서버에서 실행할 수 있지만, 일부 머신 러닝 문제는 알고리즘이 방대하거나 데이터 학습 셋이 너무 커서 하나의 기계나 서버만 실행하기 어렵습니다. 그래서, 하나의 서버에서 처리하지 않고 여러 대의 서버에서 데이터를 처리합니다. 맥 축소 접근법 (Map Reduce)은 여러 대의 서버에서 알고리즘을 병렬로 처리할 수 있게 도와줍니다. 맵 축소 접근법은 확률적 경사 하강법만큼 중요할 뿐만 아니라, 어떤 면에서는 확률적 경사 하강법보다 훨씬 더 중요한 아이디어입니다.


   맵 축소 접근법은 병렬로 처리할 서버의 대수만큼 학습 데이터 셋을 균등 분할합니다. 각 서버에서 데이터 셋의 배치 경사 하강법 업데이트의 합산을 처리하고 결과를 중앙의 마스터 서버로 전송합니다. 마스터 서버는 부분 합계를 취합하여 배치 경사 하강법 업데이트를 완료합니다. 


   따라서, 맵 축소 접근법은 병렬로 처리하는 서버의 대수만큼 성능을 향상할 수 있습니다. 예를 들어, 10대의 서버를 병렬로 처리할 경우 10배의 성능 향상이 가능합니다. 실제로는 네트워크 지연, 결과 합산 오버헤드 등으로 인해 예상보다 약간 저하될 수 있습니다.  


   맵 축소 접근법을 활용하기 위했서는 학습 셋에 대한 함수의 합산으로 표현할 수 있어야 합니다. 즉, 분리하여 학습 셋을 계산한 값과 학습 셋을 합쳐서 계산한 값이 같아야 합니다. 함수가 선형적이어야 가능합니다. 


   맵 축소 접근법은 데이터 센터에 있는 여러 대의 서버를 대상으로 사용할 수 있지만, 여러 개의 CPU를 장착한 서버나 여러 개의 코어를 가진 서버에서 충분히 활용할 수 있습니다.  여러 시스템에서 병렬화하는 것이 아니어서 단일 서버 내에서 코어를 병렬화하기 때문에 네트워크 지연을 걱정할 필요가 없습니다.


   병렬 처리를 위해 맵 축소 접근법을 반드시 사용할 필요는 없습니다. 선형 대수 라이브러리 중 어떤 것들은 서버 내의 여러 코어에 걸쳐서 연산을 자동으로 병렬하기도 하고, 학습 알고리즘의 벡터화 구현이 아주 좋은 경우에도 연산이 빠르기 때문에 병렬 처리를 시도할 필요가 없습니다.



문제 풀이


   10개의 서버에서 인공신경망을 훈련하기 위해 맵 축소 방법을 적용할 것입니다. 각 반복에서 각 서버가 무엇을 할 것인가요?

정답은 2번입니다. 

매거진의 이전글 앤드류 응의 머신러닝(17-5): 온라인 학습 알고리즘

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari