brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Dec 14. 2020

앤드류 응의 머신러닝(17-1): 빅데이터로 학습하기

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



Large Scale Machine Learning   

(대규모 머신러닝)


Gradient Descent with Large Datasets

(대규모 데이터셋과 경사 하강법)      


Learning With Large Datasets (대규모 데이터셋으로 학습하기)


   In the next few videos, we'll talk about large scale machine learning. That is, algorithms but dealing with big data sets. If you look back at a recent 5 or 10-year history of machine learning. One of the reasons that learning algorithms work so much better now than even say, 5-years ago, is just the sheer amount of data that we have now and that we can train our algorithms on. In these next few videos, we'll talk about algorithms for dealing when we have such massive data sets.


   이번 몇 개의 강의는 대규모 데이터를 다루는 머신 러닝에 대해 설명합니다. 알고리즘과 함께 빅 데이터 셋 입장에서 봅니다. 최근 5년 또는 10년을 뒤돌아 볼 때, 머신 러닝이 5년 전보다 지금이 훨씬 더 잘 동작하는 이유 중에 하나는 알고리즘이 학습할 수 있는 엄청난 양의 데이터 때문입니다. 다음 몇 개의 강의에서 엄청난 양의 데이터 셋이 있을 때 처리하는 알고리즘을 다룹니다. 


     

   So why do we want to use such large data sets? We've already seen that one of the best ways to get a high performance machine learning system, is if you take a low-bias learning algorithm, and train that on a lot of data. And so, one early example we have already seen was this example of classifying between confusable words. So, for breakfast, I ate two (TWO) eggs and we saw in this example, these sorts of results, where, you know, so long as you feed the algorithm a lot of data, it seems to do very well. And so it's results like these that has led to the saying in machine learning that often it's not who has the best algorithm that wins. It's who has the most data. So you want to learn from large data sets, at least when we can get such large data sets. 


   왜 대규모 데이터 셋을 사용할까요? 고성능 머신러닝 시스템을 개발하는 가장 좋은 방법 중 하나는 편향이 적은 학습 알고리즘을 사용하여 많은 데이터를 학습하는 것입니다. 지난 강의에서 혼동될 수 있는 단어를 구분하는 알고리즘을 다루었습니다. 예를 들면, 알고리즘은 "I ate ( ) eggs" 문장에서 'to', 'two', 'too' 중에서 들어갈 단어인 'two'를 결정합니다. 알고리즘이 많은 데이터를 학습할수록 매우 잘 동작합니다. 이런 결과로 인해 머신러닝 분야에서 최후의 승자는 최고의 알고리즘을 가진 사람이 아니라 최고의 데이터를 가진 사람이다라고 말하기도 합니다. 따라서, 방대한 양의 데이터 셋을 적극적으로 활용해야 합니다. 



   But learning with large data sets comes with its own unique problems, specifically, computational problems. Let's say your training set size is M equals 100,000,000. And this is actually pretty realistic for many modern data sets. If you look at the US Census data set, if there are, you know, 300 million people in the US, you can usually get hundreds of millions of records. If you look at the amount of traffic that popular websites get, you easily get training sets that are much larger than hundreds of millions of examples. And let's say you want to train a linear regression model, or maybe a logistic regression model, in which case this is the gradient descent rule. And if you look at what you need to do to compute the gradient, which is this term over here, then when M is a hundred million, you need to carry out a summation over a hundred million terms, in order to compute these derivatives terms and to perform a single step of decent. Because of the computational expense of summing over a hundred million entries in order to compute just one step of gradient descent,


   하지만 방대한 데이터셋을 처리하기 위해서는 연산 문제가 항상 따라다닙니다. 학습 셋 크기 m = 100,000,000과 같다고 가정합니다. 이것은 오늘날 매우 현실적인 데이터 셋의 크기입니다.  미국 인구 조사 데이터 셋은 3억 명의 사람들에 대한 수억 개의 기록이 있습니다. 인기 있는 웹사이트에서 발생하는 트래픽의 양은 수억 개의 예제보다 훨씬 더 많은 학습 셋을 쉽게 확보할 수 있습니다. 선형 회귀 모델 또는 로지스틱 회귀 모델이 이 데이터를 학습한다고 가정합니다. 학습을 위해 경사 하강법을 활용합니다. 경사를 계산하기 위한 미분항의 m이 1억이라면 1억 번 합산한 후 하나의 스텝만 움직입니다. 경사 하강법의 한 스텝을 계산하기 위해 1억 개가 넘는 항목을 합산하는 계산 비용은 엄청납니다. 



   In the next few videos we've spoken about techniques for either replacing this with something else or to find more efficient ways to compute this derivative. By the end of this sequence of videos on large scale machine learning, you know how to fit models, linear regression, logistic regression, neural networks and so on even today's data sets with, say, a hundred million examples. Of course, before we put in the effort into training a model with a hundred million examples, We should also ask ourselves, well, why not use just a thousand examples. Maybe we can randomly pick the subsets of a thousand examples out of a hundred million examples and train our algorithm on just a thousand examples. So before investing the effort into actually developing and the software needed to train these massive models is often a good sanity check, if training on just a thousand examples might do just as well. 


   다음 몇 개의 강의에서 이것을 대체하거나 효율적으로 계산하는 방법을 찾는 기술을 설명할 것입니다. 대구모 머신러닝에 대한 강의가 끝날 무렵에 선형 회귀 모델, 로지스틱 회귀 모델, 인공 신경 말 모델 등을 오늘날의 데이터 셋에 맞추는 방법을 이해할 것입니다. 물론, 1억 개의 예제를 학습하기 전에 한 번 즈음 고민해야 합니다. 알고리즘이 1억 개의 예제에서 무작위로 선택하고 단지 1,000개의 예제로 학습할 수 있습니다. 실제로 개발을 위한 노력과 시간을 투자하기 전에 그리고 알고리즘은 타당성 검사 (a sanity check)를 할 필요가 있습니다. 타당성 검사를 위해 대규모 데이터에서 무작위로 1,000개의 예제를 선택하여 학습합니다.


   The way to sanity check of using a much smaller training set might do just as well, that is if using a much smaller n equals 1000 size training set, that might do just as well, it is the usual method of plotting the learning curves, so if you were to plot the learning curves and if your training objective were to look like this, that's Jtrain(theta). And if your cross-validation set objective, Jcv of theta would look like this, then this looks like a high-variance learning algorithm, and we will be more confident that adding extra training examples would improve performance. Whereas in contrast if you were to plot the learning curves, if your training objective were to look like this, and if your cross-validation objective were to look like that, then this looks like the classical high-bias learning algorithm.   And in the latter case, you know, if you were to plot this up to, say, m equals 1000 and so that is m equals 500 up to m equals 1000, then it seems unlikely that increasing m to a hundred million will do much better and then you'd be just fine sticking to n equals 1000, rather than investing a lot of effort to figure out how the scale of the algorithm. Of course, if you were in the situation shown by the figure on the right, then one natural thing to do would be to add extra features, or add extra hidden units to your neural network and so on, so that you end up with a situation closer to that on the left, where maybe this is up to n equals 1000, and this then gives you more confidence that trying to add infrastructure to change the algorithm to use much more than a thousand examples that might actually be a good use of your time. 


   훨씬 더 작은 학습 셋을 사용하여 타당성 검사 (a sanity check)를 하는 것이 좋습니다.  학습 셋의 크기 m = 1,000과 같을 때 학습 곡선을 그리는 것은 유용합니다. 학습 셋을 활용한 파란색 곡선과 같은 학습 곡선 Jtrain(θ)가 있습니다. 교차 검증 셋에서 학습 곡석은 빨간색 곡선과 같은 Jcv(θ)가 있습니다. 높은 분산이 있는 학습 알고리즘처럼 보입니다. 학습 예제를 추가하면 성능이 향상될 것이라고 확신할 수 있습니다. 반대로 학습 곡선이 우측의 그림처럼 Jtrain(θ)와 Jcv(θ)을 그린다면 일반적인 편향 학습 알고리즘처럼 보입니다. 그리고 우측 그림은 m = 500일 때와 m = 1,000 일 때를 보면 m = 100,000,000 일지라도 엄청난 성능 개선이 있을 것 같지 않습니다. 알고리즘의 규모를 파악하기 위해 많은 노력을 기울이는 것보다 m= 1,000을 고수하는 것이 좋습니다. 물론, 오른쪽 그림과 같은 상황이라면 자연스럽게 피처를 추가하거나 인공 신경망에 은닉 유닛을 추가합니다. 왼쪽 그림은 인프라를 추가하고 알고리즘을 변경하면 실제로 좋은 결과를 얻을 수 있습니다. 



   So in large-scale machine learning, we like to come up with computationally reasonable ways, or computationally efficient ways, to deal with very big data sets. In the next few videos, we'll see two main ideas. The first is called stochastic gradient descent and the second is called Map Reduce, for dealing with very big data sets. And after you've learned about these methods, hopefully that will allow you to scale up your learning algorithms to big data and allow you to get much better performance on many different applications.


   따라서, 대규모 머신 러닝에서 매우 큰 데이터 셋을 처리하기 위해 계산적으로 합리적인 방법이나 효율적인 방법을 찾아야 합니다. 다음 몇 개의 강의에서 두 가지 아이디어를 다룰 것입니다. 첫 번째는 확률적 경사 하강법이고, 두 번째는 매우 큰 데이터 셋을 다루는 Map Reduce입니다. 이런 방법을 공부한 후에 학습 알고리즘을 빅데이터로 확장하고 여러 응용 사례에서 더 나은 성능을 발휘할 수 있습니다.


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




정리하여


   오늘날의 IT 시스템들은 엄청나게 방대한 데이터를 생산합니다. 빅데이터를 제대로 다룰 수 있다면, 지금까지 우리가 보지 못했던 많은 것들을 볼 수 있습니다.   



   It's not who has the best algorithm that wins, it's who has the most data. 


 머신러닝 분야에서 최후의 승자는 최고의 알고리즘을 가진 사람이 아니라 최고의 데이터를 가진 사람이다라고 말하기도 합니다.



   알고리즘이 빅 데이터를 직접 계산하기 위해 엄청난 계산 비용과 시간을 들이기 전에 먼저 타당성 검사 (a sanity check)를 해야 합니다. 무작위로 1,000개의 학습 예제를 추출하여 학습 곡선을 그립니다. 학습 고선으로 데이터가 많을수록 알고리즘이 좋은 결과를 만드는지 아닌 지를 확인합니다.



문제 풀이


   지금까지 정규화를 다루었습니다. 피처 스케일링과 달리 영화 펴라 등급의 범위를 그대로 두었습니다. 이유는 무엇일까요?

정답은 4번입니다.



매거진의 이전글 앤드류 응의 머신러닝(16-6): 협업 필터링 정규화
작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari