brunch

You can make anything
by writing

C.S.Lewis

by 라인하트 Nov 04. 2020

앤드류 응의 머신러닝(10-7): 작업 우선 순위 결정

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


Advice for Applying Machine Learning 

머신 러닝 적용을 위한 조언 


Bias vs. Variance (편향과 분산)  


Deciding What to Do Next Revisited (작업 우선순위 결정)        



   We've talked about how to evaluate learning algorithms, talked about model selection, talked a lot about bias and variance. So how does this help us figure out what are potentially fruitful, potentially not fruitful things to try to do to improve the performance of a learning algorithm.


   학습 알고리즘을 평가하는 방법, 모델 선택, 편향 및 분산을 설명했습니다. 학습 알고리즘의 성능을 개선하기 위해 필요한 작업과 불필요한 작업을 어떻게 파악할 수 있을까요? 

     


   Let's go back to our original motivating example and go for the result. So here is our earlier example of maybe having fit regularized linear regression and finding that it doesn't work as well as we're hoping. We said that we had this menu of options. So is there some way to figure out which of these might be fruitful options? The first thing all of this was getting more training examples. What this is good for, is this helps to fix high variance. And concretely, if you instead have a high bias problem and don't have any variance problem, then we saw in the previous video that getting more training examples, while maybe just isn't going to help much at all. So the first option is useful only if you, say, plot the learning curves and figure out that you have at least a bit of a variance, meaning that the cross-validation error is, you know, quite a bit bigger than your training set error. 

   How about trying a smaller set of features? Well, trying a smaller set of features, that's again something that fixes high variance. And in other words, if you figure out, by looking at learning curves or something else that you used, that have a high bias problem; then for goodness sakes, don't waste your time trying to carefully select out a smaller set of features to use. Because if you have a high bias problem, using fewer features is not going to help. Whereas in contrast, if you look at the learning curves or something else you figure out that you have a high variance problem, then, indeed trying to select out a smaller set of features, that might indeed be a very good use of your time. 

   How about trying to get additional features, adding features, usually, not always, but usually we think of this as a solution for fixing high bias problems. So if you are adding extra features it's usually because your current hypothesis is too simple, and so we want to try to get additional features to make our hypothesis better able to fit the training set. And similarly, adding polynomial features; this is another way of adding features and so there is another way to try to fix the high bias problem. And, if concretely if your learning curves show you that you still have a high variance problem, then, you know, again this is maybe a less good use of your time. 

   And finally, decreasing and increasing lambda. This are quick and easy to try, I guess these are less likely to be a waste of, you know, many months of your life. But decreasing lambda, you already know fixes high bias. In case this isn't clear to you, you know, I do encourage you to pause the video and think through this that convince yourself that decreasing lambda helps fix high bias, whereas increasing lambda fixes high variance. And if you aren't sure why this is the case, do pause the video and make sure you can convince yourself that this is the case. Or take a look at the curves that we were plotting at the end of the previous video and try to make sure you understand why these are the case.


   기대만큼 잘 동작하지 않는 정규화된 선형 회귀 알고리즘이 있습니다. 알고리즘의 성능을 개선하기 위해 어떤 옵션을 적용해야 할까요? 첫 번째 옵션은 더 많은 학습 예제를 구하는 것입니다. 더 많은 학습 예제는 높은 분산을 교정하지만, 높은 편향 문제가 있고 분산 문제가 없는 경우 전혀 도움이 되지 않습니다. 첫 번째 옵션은 학습 곡선을 도식화하고 최소한 약간의 분산이 있다는 것을 파악할 때 유용합니다. 즉, 교차 검증 오차가 학습 오차보다 훨씬 더 커야 합니다.  

   다음은 더 작은 피처 셋을 사용하는 옵션입니다. 더 적은 피처 셋은 높은 분산을 교정합니다. 학습 곡선이나 다른 것을 살펴보면서 높은 편향 문제를 발견하면 더 적은 피처를 신중하게 선택하기 위해 시간을 낭비하지 마세요. 높은 편향 문제에 더 적은 피처 셋은 전형 도움이 되지 않습니다. 반면에 분산 문제가 클 경우에 더 적은 피처 셋을 만들기 위해 시간을 투자할 가치가 있습니다. 

    세 번째 옵션은 피처 셋을 추가하는 것입니다. 일반적으로 높은 편향 문제에 대한 해결책으로 생각합니다. 현재 가설이 너무 단순하기 때문에 가설이 학습 셋에 더 잘 맞도록 피처를 추가합니다. 피처를 추가하는 방법은 높은 편향 문제를 해결합니다. 그리고, 학습 곡선이 여전히 높은 분산 문제를 보여준다면 사용할 필요는 없습니다. 

   마지막으로 정규화 파라미터 λ를 줄이거나 늘립니다. 이것은 빠르고 쉽게 시도할 수 있습니다. 정규화 파라미터  λ가 여러분의 시간을 몇 달씩 낭비하게 하지 않을 것입니다. 그러나,  λ를 줄이면 높은 편향 문제를 교정합니다. 

   지금까지의 설명이 잘 이해되지 않는다면, 영상을 일시 중지하고 다시 살펴봅니다. 정규화 파라미터 λ를 줄이면 높은 편향을 교정하고 λ를 늘리면 높은 분산을 교정합니다. 아니면 지난 강의를 다시 보고 왜 그런 지를 이해합니다. 



   Finally, let us take everything we have learned and relate it back to neural networks and so, 

here is some practical advice for how I usually choose the architecture or the connectivity pattern of the neural networks I use. So, if you are fitting a neural network, one option would 

be to fit, say, a pretty small neural network with you know, relatively few hidden units, maybe just one hidden unit. If you're fitting a neural network, one option would be to fit a relatively small neural network with, say, relatively few, maybe only one hidden layer and maybe only a relatively few number of hidden units. So, a network like this might have relatively few parameters and be more prone to underfitting.The main advantage of these small neural networks is that the computation will be cheaper.


   마지막으로 인공 신경망에 대해 고려해 봅니다. 신경망 아키택처 또는 연결 패턴을 선택하는 방법에 대한 실무적인 조언이 있습니다. 한 가지 옵션은 꽤 작은 인공 신경망에 적합시키는 것입니다. 비교적 적은 수의 은닉 유닛, 아마도 하나의 은닉 유닛일 수도 있습니다. 인공 신경망에 적합시키는 한 가지 옵션은 상대적으로 적은 수 하나의 은닉층과 상대적으로 적은 수의 은닉 유닛으로 상대적으로 작은 인공 신경망을 설계하는 것입니다. 파라미터의 수가 상대적으로 적어서 과소 적합에 취약할 수 있습니다. 작은 인공 신경망의 장점은 계산 비용이 더 저렴하다는 것입니다.  


   An alternative would be to fit a, maybe relatively large neural network with either more hidden units--there's a lot of hidden in one there--or with more hidden layers. And so these neural networks tend to have more parameters and therefore be more prone to overfitting. One disadvantage, often not a major one but something to think about, is that if you have a large number of neurons in your network, then it can be more computationally expensive. Although within reason, this is often hopefully not a huge problem. The main potential problem of these much larger neural networks is that it could be more prone to overfitting and it turns out if you're applying neural network very often using a large neural network often it's actually the larger, the better but if it's overfitting, you can then use regularization to address overfitting, usually using a larger neural network by using regularization to address is overfitting that's often more effective than using a smaller neural network. And the main possible disadvantage is that it can be more computationally expensive.


   다른 옵션은 더 많은 은닉 유닛과 더 많은 은닉층으로 상대적으로 큰 인공 신경망을 설계하는 것입니다. 상대적으로 큰 인공 신경망은 더 많은 파라미터를 갖고 과적합하는 경향이 있습니다. 한 가지 단점은 많은 수의 뉴런이 있는 경우 계산 비용이 많이 들 수 있다는 것입니다. 이것은 그리 큰 문제는 아닙니다. 대규모 신경망은 과적합 가능성이 높습니다. 인공 신경망은 실제로 더 클수록 좋지만 과적합할 확률도 높습니다. 정규화 파라미터를 사용하면서 더 큰 인공 신경망을 사용하는 것이 더 작은 신경망을 사용하는 것보다 더 효과적입니다. 단점은 계산 비용이 많이 들 수 있다는 것입니다. 

    

   And finally, one of the other decisions is, say, the number of hidden layers you want to have, right? So, do you want one hidden layer or do you want three hidden layers, as we've shown here, or do you want two hidden layers? And usually, as I think I said in the previous video, using a single hidden layer is a reasonable default, but if you want to choose the number of hidden layers, one other thing you can try is find yourself a training cross-validation, and test set split and try training neural networks with one hidden layer or two hidden layers or three hidden layers and see which of those neural networks performs best on the cross-validation sets. You take your three neural networks with one, two and three hidden layers, and compute the cross validation error at Jcv and all of them and use that to select which of these is you think the best neural network.


   마지막으로 은닉층의 수를 결정해야 합니다. 하나의 은닉층을 좋습니까? 아니면 세 개의 은닉층을 좋습니까? 아니면 두 개의 은닉층을 원합니까? 일반적으로 단일 은닉층을 사용하는 것이 합리적인 기본값이지만, 은닉층의 수를 선택할 때 시도할 수 있는 방법은 학습 및 교차 검증 셋을 찾는 것입니다. 데이터 셋을 분할하여 1 개의 은닉층, 2 개의 은닉층, 또는 3 개의 은닉층을 사용하여 인공 신경망 학습을 시도하고 교차 검증 셋에서 가장 잘 수행되는 인공 신경망을 선택합니다. 교차 검증 오류 Jcv(θ)의 값이 가장 작은 인공 신경망을 선택합니다.   


   

So, that's it for bias and variance and ways like learning curves, who tried to diagnose these problems. As far as what you think is implied, for one might be truthful or not truthful things to try to improve the performance of a learning algorithm.


   이것이 편향과 분산, 그리고 문제를 진단하는 학습 곡선입니다. 학습 알고리즘의 성능을 향상하기 위해 참이거나 참이 아닐 수 있습니다. 

      

   If you understood the contents of the last few videos and if you apply them you actually be much more effective already and getting learning algorithms to work on problems and even a large fraction, maybe the majority of practitioners of machine learning here in Silicon Valley today doing these things as their full-time jobs. So I hope that these pieces of advice on by experience in diagnostics will help you to much effectively and powerfully apply learning and get them to work very well.


   지난 몇 개의 강의의 내용을 이해하고 적용하면 훨씬 더 효과적인 학습 알고리즘이 문제를 해결하는 데 도움이 됩니다. 오늘날 실리콘 밸리의 머신러닝 실무자 대다수가 이것들을 사용합니다. 따라서, 진단 경험을 통해 얻은 이러한 조언이 학습을 훨씬 효과적이고 강력하게 적용하고 학습 알고리즘이 잘 작동하도록 도움이 되기를 바랍니다. 



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




정리하며 - 작업 우선순위 결정하기


   학습 알고리즘을 개선하기 위한 작업들은 각각의 역할이 있습니다. 


1) 더 많은 학습 예제 수집하기 : 높은 분산 교정

2) Feature 셋의 크기 줄이기 : 높은 분산 교정

3) Feature 셋의 크기 늘리기 : 높은 편향 교정

4) 다항식 추가하기                : 높은 편향 교정

5) 정규화 파라미터 λ값을 줄이기 : 높은 편향 교정

6) 정규화 파라미터  λ값을 늘리기 : 높은 분산 교정

 

    교차 검증 셋을 활용한 검증 및 학습 곡선을 통해 편향과 편차를 확인하면 위의 6 가지 방법 중에 하나를 취할 수 있습니다. 차수가 낮은 다항식은 높은 편향을 갖고, 차수가 높은 다항식은 높은 편차를 갖습니다. 


 

   처음 인공 신경망은 작은 신경망을 설계합니다. 비교적 적은 수의 은닉 유닛 수와 은닉층을 설계합니다. 만일, 파라미터의 수가 상대적으로 적으면 과소 적합에 취약할 수 있지만, 계산 비용이 더 저렴하다는 장점이 있습니다. 


   다른 옵션은 더 많은 은닉 유닛과 더 많은 은닉층으로 상대적으로 큰 인공 신경망을 설계하는 것입니다. 상대적으로 큰 인공 신경망은 더 많은 파라미터를 갖고 과적합하는 경향이 있습니다. 한 가지 단점은 많은 수의 뉴런이 있는 경우 계산 비용이 많이 들 수 있습니다.   


   마지막으로 은닉층의 수를 결정해야 합니다. 은닉 유닛의 수를 결정할 때는 다음과 같은 방법을 사용합니다.


1) 데이터 셋을 분할

2) 1 개의 은닉층, 2 개의 은닉층, 또는 3 개의 은닉층을 사용하여 인공 신경망 학습을 시도

2) 교차 검증 오류 Jcv(θ)의 값이 가장 작은 인공 신경망을 선택


   정규화 파라미터를 사용하면서 더 큰 인공 신경망을 사용하는 것이 더 작은 신경망을 사용하는 것보다 더 효과적입니다. 



문제 풀이


   하나의 은닉층을 가진 인공 신경망이 있습니다. 교차 검증 오류는 학습 오류보다 큽니다. 은닉 유닛의 수를 늘리는 것은 도움이 될까요?

정답은 4번입니다. 



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