본문 바로가기

머신러닝/[기타]

Types of Learning in Machine Learning

Supervised, Unsupervised, Transductive, Inductive...

똑같이 모델을 학습시키는데 무슨 방법론이 이렇게 많은지...

간략하게라도 전체에 대한 카테고라이징을 해두면 좋겠다 싶었는데,

적당한 글을 발견하여 번역한다.

츨처: 링크1, 링크2


"Machine Learning" 은 특정 필드에 종속되는 연구가 아닌, 정말 다양한 필드에 적용가능한 연구이다.

여기서 핵심은, "Learning" 이라고 할 수 있는데, 말 그대로, 데이터셋(=경험)으로부터 다양한 지식을 획득하는 것에 있다.

해당 글에서는, 이런 "Learning" 의 종류가 어떻게 분류되는지에 대한 이야기를 할 것.


Types of Learning

일단, 학습 방법의 종류는 아래와 같이 분류될 수 있을 것 같다.

  • Learning Problems
      1. Supervised Learning
      1. Unsupervised Learning
      1. Reinforcement Learning
  • Hybrid Learning Problems
      1. Semi-Supervised Learning
      1. Self-Supervised Learning
      1. Multi-Instance Learning
  • Statistical Inference
      1. Inductive Learning
      1. Deductive Inference
      1. Transductive Learning
  • Learning Techniques
      1. Multi-Task Learning
      1. Active Learning
      1. Online Learning
      1. Transfer Learning
      1. Ensemble Learning

14개? 어으 뒤질나게 많다.


Learning Problems

그래도 가장 친숙한 친구들이 많이 포진되어 있는 줄기이다.

하나하나, 다시 살펴보자.

1. Supervised Learning

지도 학습... 이란 Input과 Target간의 mapping function을 배워나가는 학습 방법이다.

대개, 지도 학습에서는 $(X,y)$로 표현되는, 라벨링이 달린 데이터셋을 이용해 학습이 진행하는데,

같은 의미.

모델의 예측값과 라벨을 비교해나가면서, 계속적으로 mapping function을 update하는 방식이겠쥬?

이런 라벨 $y$가 마치 선생같은 역활을 한다고 해서 Supervised.

"Applications in which the training data comprises examples of the input vectors along with their corresponding target vectors are known as supervised learning problems"

— Page 3, Pattern Recognition and Machine Learning, 2006.

이런 지도 학습은 다시 2가지 유형으로 대표되는데,

  • Classification: Supervised learning problem that involves predicting a class label.
  • Regression: Supervised learning problem that involves predicting a numerical label.

Decision trees, SVM 따위가 Supervised Learning에 속하며, Logistic regression과 같이 분류만을 위해 설계된 모델도 있지만, Neural network과 같이 분류와 회귀를 모두 처리할 수 있는 모델도 있다.

2. Unsupervised Learning

비지도 학습... 은 데이터간의 관계를 설명하거나 추출하는 function을 배워나가는 학습 방법이다.

지도학습과 달리 오직 $X$ 로 표현되는 데이터만을 가지고 있을 뿐, $y$가 없기 때문에 모델을 수정해나가는 선생이 없다.

"In unsupervised learning, there is no instructor or teacher, and the algorithm must learn to make sense of the data without this guide"

— Page 105, Deep Learning, 2016.

이런 비지도 학습도 2가지 유형으로 대표되는데, (대표된다는거지 이거만 있다는 거 아님)

  • Clustering: Unsupervised learning problem that involves finding groups in data.
  • Density Estimation: Unsupervised learning problem that involves summarizing the distribution of data.

Clustering에서 대표적인 친구가 이제 K-means. 그 K 개라는 hyperparameter를 미리 선택해주면, 전체 데이터셋에서 랜덤하게 K 개의 포인트 잡고 다른 점들이랑 거리 재서 서서히 군집의 센터를 찾아가던 그것.

Density Estimation에서는 Kernel Density Estimation (KDE)가 있다. 이건 이 글이 설명이 읏된다.

추가적으로, 비지도학습은 시각화 또는 저차원으로의 사영에도 자주 활용된다.

  • Visualization: Unsupervised learning problem that involves creating plots of data.
  • Projection: Unsupervised learning problem that involves creating lower-dimensional representations of data.

Visualization은 뭐 별다른게 아니라, 그냥 주어진 데이터를 다양한 형태로 시각화 할 수 있는데, 예를 들어 똑같은 데이터라도 Histogram, Line plot, Violin plot... 등 으로 표현할 수 있으니까... 그거 자체가 하나의 Unsupervised learning 이라는 듯 하고,

Projection은 시각화할 때도 유용하고, feature selection 과정에서도 쓸 수 있고 뭐 이런데, PCA나 T-SNE 등이 있겠다.

"The goal in such unsupervised learning problems may be to discover groups of similar examples within the data, where it is called clustering, or to determine the distribution of data within the input space, known as density estimation, or to project the data from a high-dimensional space down to two or three dimensions for the purpose of visualization."

— Page 3, Patter Recognition and Machine Learning, 2006.

3. Reinforcement Learning

강화 학습... 은 주어진 Environment 위에서 행동하는 Agent가 Feedback을 통해서 무언가를 배워나가는 학습 방법이다.

"Reinforcement learning is learning what to do - how to map situations to actions - so as to maximize a numerical reward signal. The learner is not told which actions to take, but instead must discover which actions yield the most reward by trying them."

— Page 1, Reinforcement Learning: An Introduction, 2nd edition, 2018.

Environment 를 사용한다는 말은 고정된 훈련용 데이터셋이 존재하지 않는다는 것을 말한다.

이해를 위해 조금 더 구체적으로 Environment를 생각해보면, 음, 카트라이더를 강화학습으로 가르치고 싶다? 그럼 키보드의 앞뒤양옆 화살표, 쉬프트 그리고 컨트롤? 이라고 말할 수 있을 것 같다.

쨋든, 특정 데이터셋을 활용하는 것이 아니라, Agent가 달성해야할 목표, 그리고 수행할 수 있는 Action, 해당 Action의 Feedback으로 활용할 수 있는 Reward라는 개념을 활용한다.

"Some machine learning algorithms do not just experience a fixed dataset. For example, reinforcement learning algorithms interact with an environment, so there is a feedback loop between the learning system and its experiences."

— Page 105, Deep Learning, 2016.

Reward를 보고 다시 모델이 업데이트 된다는 측면에서는, Supervised learning과 비슷할지도 모른다. 하지만, Supervised learning에서는 그런 에러가, 로스가, 즉각적으로 반응이 온다면

Reinforcement learning에서는, 단일 Actions에 대한 즉각적인 Reward가 나오는 개념이 아니라, 최종 결과를 통해 전달되므로, 음 Feedback이 Delayed되고, 또 음 Smoothing된다랄까...? 그런 점에서 좀 차이가 있는 거다.

"In many complex domains, reinforcement learning is the only feasible way to train a program to perform at high levels. For example, in game playing, it is very hard for a human to provide accurate and consistent evaluations of large numbers of positions, which would be needed to train an evaluation function directly from examples. Instead, the program can be told when it has won or lost, and it can use this information to learn an evaluation function that gives reasonably accurate estimates of the probability of winning from any given position"

— Page 831, Artificial Intelligence: A Modern Approach, 3rd edition, 2015.

아는 것 처럼, AlphaGo가 흥했지?

Q-Learning, Temporal-difference learning 그리고 Deep reinforcement learning 등이 있다.

Hybrid Learning Problems

위에서 Supervised, Unsupervised 말을 했지만, 사실 이게 항상 명확히 나뉘어 사용되지는 않고, Hybrid 하게 많이 사용이 된다.

생각해봐 데이터가 뒤지게 많아도, 라벨링 된건 별로 없을 수 있잖아.

Supervised 입장에서는, 그렇다고 라벨링 안된건 다 안쓴다? 너무 아깝지

Unsupervised 입장에서는, 라벨링 된거도 추가로 쓰면 당연히 더 좋을 것 같네

그거에 대해 한 번 이야기를 해보자.

4. Semi-Supervised Learning

준지도 학습... 은 $(X,y)$ 랑 $X$ 랑 같이 쓰는 학습 방법, 근데 라벨링된 데이터가 많이 없는 경우가 많겠다.

Supervised와 Unsupervised의 스까묵기. 생각해보면 이런 접근방법의 발생은 자연스럽다.

"In semi-supervised learning we are given a few labeled examples and must make what we can of a large collection of unlabeled examples. Even the labels themselves may not be the oracular truths that we hope for."

— Page 695, Artificial Intelligence: A Modern Approach, 3rd edition, 2015.

레이블이 없는 데이터를 어떻게 활용할까? 에서는 Unsupervised의 Clustering, Density Estimation idea를 활용할 필요가 있다.

가령, 어떤 데이터의 라벨이 없더라도, Clustering을 통해, 새로 라벨을 지정해주는 접근이 가능. 또는 같은 그룹에 있는 데이터들끼리는 representation이 비슷해야할 것이라는 직관이 있는데, 이를 활용할 수도 있겠다.

"Unsupervised learning can provide useful cues for how to group examples in representation space. Examples that cluster tightly in the input space should be mapped to similar representations"

— Page 243, Deep Learning, 2016.

5. Self-Supervised Learning

자가지도 학습... 은 $X$만을 이용하는 지도 학습이라고 말할 수있을 것 같다.

? $y$ 없이 우째 지도 학습을 하노 ?

$(X,X)$ 로 학습하면 되지 않을까 ㅎㅎ; 하는 개념.

이런 자가지도 학습은 자기 자신을 어느정도 잘 표현하는 representation을 학습하는데 주로 사용된다.

"The self-supervised learning framework requires only unlabeled data in order to formulate a pretext learning task such as predicting context or image rotation, for which a target objective can be computed without supervision."

— Revisiting Self-Supervised Visual Representation Learning, 2019.

BERT의 cloze-task를 생각해봐도 좋을 것 같다.

우리가 책에 대한 텍스트 데이터가 굉장히 많고, 각 책마다 토픽이 어떤건지 학습하기를 원했다.

그럼 바로 $(X,y)$를 학습시켜도 되지만, 그전에 $X$를 내가 좀 어떻게 핸들링을 잘 해서?

$X$에 이제 여러 문장 $x_i$ 가 들어있으면 $x_i$ 다음에는 $x_{i+1}$ 가 와야되는걸 미리 학습을 시켜두면,

문장 순서를 고려한 initial representation을 얻을 수 있다 뭐 이런 개념?

Auto-encoder 도 좋은 예시다. $X$ 가 굉장히 고차원이라 이걸 바로 어떤 모델의 인풋으로 활용하기가 부담된다면,

이걸 저차원으로 임베딩시키는 것도 좋은 접근 방법이 될텐데,

이런 저차원 임베딩을 어떻게 구할 것인가? 에 대한 문제를 간단히 해결한 것.

이건 $(X,X)$ 를 이용한 지도학습.

자세한 구조는 알 것이라 생각하고 생략.

Generative Adversarial Networks(GAN) 도 자가지도 학습 ㅋㅋ

레이블이 없는 데이터만 활용해서 합성사진을 만들어내는게 신박하다.

이것도 자세한 구조는 생략.

"The generator network directly produces samples. Its adversary, the discriminator network, attempts to distinguish between samples drawn from the training data and samples drawn from the generator. The discriminator emits a probability value given by $d(x; \theta(d))$, indicating the probability that x is a real training example rather than a fake sample drawn from the model."

— Page 699, Deep Learning, 2016.

6. Multi-Instance Learning (MIL)

다중 인스턴스 학습... 은 Clustering을 좀 이용한 그런 지도학습? 의 느낌인데, 개별 샘플마다 레이블이 지정된게 아니라, Bags or groups of samples are labeled.

"In multi-instance learning, an entire collection of examples is labeled as containing or not containing an example of a class, but the individual members of the collection are not labeled."

— Page 106,

이런 샘플들을 이제 인스턴스라고 지칭할텐데, 인스턴스들은 "Set" 이 아닌 "Bag" 에 있다고 표한한다. "Set" 은 중복을 담아내지 못하기 때문...

실제로 학습할 때, 개별 인스턴스가 아닌, 이런 Bag을 인풋으로 넣어줌으로써, 일부 라벨이 있는 인스턴스를 통해 나머지 라벨이 없는 인스턴스를에 대한 학습도 진행될 수 있도록 하는 셈이다.

이렇게 함으로써, 라벨이 없는 인스턴스로 구성된 새로운 Bag을 인풋으로 넣어도, 이것에 대한 예측이 가능해진다.

"In supervised multi-instance learning, a class label is associated with each bag, and the goal of learning is to determine how the class can be inferred from the instances that make up the bag."

— Page 156, Data Mining: Practical Machine Learning Tools and Techniques, 4th edition, 2016.

단순히, 하나의 Bag에 담긴 인스턴스들은 같은 레이블을 할당하고, 이를 통해 일반적인 지도 학습을 진행하는 것도 종종 괜찮게 작동하기도 한다.

조금 더 구체적인 예시를 들어보자면, 음 리뷰 데이터에서의 감정 분류 문제를 해결할 때를 생각해보자. - Multiple Instance Learning Networks for Fine-Grained Sentiment Analysis (TACL '18)

보통의 지도학습은, 하나의 리뷰 전체의 대한 - Document representation을 학습하여 감정 분류를 해결하지만,

이를 다중 인스턴스 학습으로 처리하겠다는 말은, Document의 많은 Sentence 각각을 하나의 인스턴스 삼아, 다양한 Bag을 형성하고, 이를 통해 학습을 진행한다.

기존 과정은, Doc에 대한 분류를 시행하기 위해서, 각 Sentences을 CNN 따위를 태워 representation을 얻어내고, 이것을 RNN 따위에 흘리고 뭐 Attention 따위를 이용해 Doc representation을 획득한 뒤 분류를 시행한다면,

다중 인스턴스 학습에서는, 각 Sentence(또는 Segmentation)에 대한 representation이 산출되고, 이런 Segmentation representation으로 바로 Sentiment classification을 수행한 다음, 이러한 결과를 조합해서 Document에 대한 분류 결과를 획득. 조합하는 과정에서 Attention 스까도 되고...

Q. 여기서는 Bag 별 Label 은 뭐가 들어가서...? 보통은 하나만 Pos면 다 Pos로 이런 식으로 하긴하는디... 논문 읽기 시로요

Q. 저 말만들으면, 결과를 aggregation 하는가, representation을 aggregation 하는가 - 밖에 차이가 없어 보인다. 구체적으로 Loss를 보고 알아보고 싶다. 그래도 결과적으로는 기존 학습 방식으로는 각 문장도 결국에는 Neg Doc 안에 있었다면 모든 Sen 들은 Neg 하되 그 정도의 차이가 있는 정도로 학습이 됬지만, 다중 인스턴스 방식으로는 Neg Doc에 있는 Sen이라도 Pos 와 Neg 가 모두 나타나더라. 아 그게 차이인가? 아?아아?

Statistical Inference

Inference, 추론은 기본적으로 결과 또는 결정을 도출하는 것을 의미한다.

개인적으로는 예측=추론으로 알고 있었는데,

ML에서, Fitting a model 그리고 Making a prediction 은 모두 추론에 해당한다.

그리고 이제부터 말하는 분류법은, 이런 추론의 관점에서의 분류 갈래.

7. Inductive Learning

단어 자체를 뜯어보면,

Inductive learning이란, 결과를 결정하기 위해서, 증거를 사용하는 것.

Inductive reasoning이란, 일반적인 결과를 결정하기 위해, 특정 예시를 사용하는 것.

말이 어려운데, 귀납적 증명을 떠올려보면, 구체적인 사실로부터 일반적인 사실을 이끌어낸다 - 였는데, 그냥 이거.

대부분의 ML model은 Inductive inference or Inductive reasoning을 이용해, 특정한 데이터셋으로부터 일반적인 규칙(모델)을 학습한다.

"...the problem of induction, which is the problem of how to draw general conclusions about the future from specific observations from the past."

— Page 77, Machine Learning: A Probabilistic Perspective, 2012.

기본적으로 Fitting a model은 Inductive하다. 모델 - 일종의 mapping function은 훈련용 데이터셋의 특정한 예제들를 일반화시킨 것이다.

모델 또는 가설이라는 개념은 훈련용 데이터셋을 통해 만들어지고, 이것은 new unseen data에 대해서도 잘 작동할 것이라는 사실은, 기본적인 ML의 가정이다.

"Lacking any further information, our assumption is that best hypothesis regarding unseen instances is the hypothesis that best fits the observed training data. This is the fundamental assumption of inductive learning"

— Page 23, Machine Learning, 1997.

8. Deductive Learning

모든 사람은 죽는다 & 소크라테스는 사람이다 → 소크라테스는 죽는다.

Q. ? 뭔 쌉소리야 그래서 예제가 뭐 있는데..?;;

9. Transductive Learning

Transductive or Transductive learning이란, 특정 예제에 대한 예측을 시행할 때, 특정 예제를 활용하는 것을 의미한다.

Induction은 특정 예제로 일반적인 규칙을 학습했지만, Transductive learning은 특정 예제에서 특정 예제로 간다는 면에서 차이가 있는 것.

추천 시스템의 많은 모델들이 Transductive, new unseen user에 대한 예측은 할 수가 없어.

Induction과 달리, 일반화가 필요없기 때문에, 단점도 분명하지만, 이로 인한 장점도 있다.

특정한 예제들을 직접적으로 사용하기 때문에, Induction 보다 학습이 더 쉬울 수 있다.

"The model of estimating the value of a function at a given point of interest describes a new concept of inference: moving from the particular to the particular. We call this type of inference transductive inference. Note that this concept of inference appears when one would like to get the best result from a restricted amount of information."

— Page 169, The Nature of Statistical Learning Theory, 1995.

Transductive 한 가장 클래식한 예시는, KNN이 있다.

new point가 들어오면 임마들 근처에 있는 친구들을 이용해 예측을 진행하니께...

어? 추천에서는 할 수가 없댔는데, KNN은 되지않나?

ㅇㅇ; 되긴함 근디 기존 가지고 있는 데이터셋이랑 터무니 없이 먼 포인트로 예측을 해봐야

정확도가... 그지깽깽이다 그죠잉...

Contrasting Induction, Deduction, and Transduction

간단하게 아래와 같은 사진으로 3 방법의 삘링을 요약할 수 있다.

Learning Techniques

10. Multi-Task Learning

Multi-Task Learning이란, Supervised의 일종인데, 하나의 데이터셋을 이용해 Multiple task를 학습시키는 것.

신기하게, Single task로 학습시킨 모델의 Single task performance보다 Multiple task로 한 방에 학습시킨 모델의 Single task performance가 더 좋은 경우가 있네? → 일반화 능력이 향상되기 때문.

"Multi-task learning is a way to improve generalization by pooling the examples (which can be seen as soft constraints imposed on the parameters) arising out of several tasks."

— Page 244, Deep Learning, 2016.

이런 접근이 유용할 때는 언제일까?

A task에 대한 라벨링 데이터가 굉장히 많아, 그런데 이 중의 일부는 B task에 대한 라벨링도 되어있다? 이런 상황에서 유용.

기존 Supervised에서는 B task를 학습시키기 위해 소수의 라벨링 데이터만 쓰면 좀 별로일 것 같은 삘링이 있다.

근데 이걸 Multi-Task learning으로 해본다?

왠지 조금 더 나아질 수 있을 것 같다는 직관이 온다.

"...we may want to learn multiple related models at the same time, which is known as multi-task learning. This will allow us to 'borrow statistical strength' from tasks with lots of data and to share it with tasks with little data."

— Page 231, Machine Learning: A Probabilistic Perspective, 2012.

"In the same way that additional training examples put more pressure on the parameters of the model towards values that generalize well, when part of a model is shared across tasks, that part of the model is more constrained towards good values (assuming the sharing is justified), often yielding better generalization."

— Page 244, Deep Learning, 2016.

이게 자연어 쪽에서 좀 유명한데, 아무래도 해당하는 상황(데이터셋)이 많이 있기 때문이 아닐까...

같은 word embedding을 통해 multiple task에 대한 학습을 진행함으로써, 더 합리적인 representation을 획득할 수 있을 듯.

11. Active Learning

Active learning이란, 모델이 학습을 하다가, 이게 좀 이상하다? 싶으면 인간한테 이거 좀 똑바로 알려줘봐 하면서 쿼리를 날릴 수 있는 방법론.

"Active learning: The learner adaptively or interactively collects training examples, typically by querying an oracle(e.g., a human annotator) to request labels for new points."

— Page 7, Foundations of Machine Learning, 2nd edition, 2018.

기본적으로 Supervised learning과 동일하다. 다만 기존의 이 친구가 좀 "Passive" 했다면, 이건 "Active" 하기 때문에, 조금 더 나은 결과를 달성할 여지가 있겠네.

"The key idea behind active learning is that a machine learning algorithm can achieve greater accuracy with fewer training labels if it is allowed to choose the data from which it learns. An active learner may pose queries, usually in the form of unalabeled data instances to be labeled by an oracle."

— Active Learning Literature Survey, 2009.

Semi-Supervised learning을 조금 더 개량한 것 처럼 보이기도 하는데, 뭐 합당한 생각이다.

"...we see that active learning and semi-supervised learning attack the same problem from opposite directions. While semi-supervised methods exploit what the learner thinks it knows about the unlabeled data, active methods attempt to explore the unknown aspects. It is therefore natural to think about combining the two."

— Active Learning Literature Survey, 2009.

이런 접근이 유용할 때는 언제일까?

일단, 라벨링된 데이터가 별로 없고, 라벨링 하는데 비용이 꽤나 비쌀 경우, 예를 들면 의학쪽 데이터들이 있겠지, Active learning을 통해 정말 필요한 라벨링만 모델이 요청하도록 하면 꽤나 유용하겠네.

이렇게 하면 최소한의 데이터로 최고의 효율을 뽑아먹을 수 있겠다.

12. Online Learning

Online Learning이란, 일단 써먹을 수 있는 데이터는 다 사용하는데, 예측 직전 또는 마지막 관측 이후에 모델을 최종적으로 업데이트 하는 것을 의미.

아마 데이터가 계속해서 변화하는 그런 상황에서 실시간 학습을 진행하는 것을 의미하는 듯.

"Traditionally machine learning is performed offline, which means we have a batch of data, and we optimize an equation. However, if we have streaming data, we need to perform online learning, so we can update our estimates as each new data point arrives rather than until 'the end'."

— Page 261, Machine Learning: A Probabilistic Perspective, 2012.

또 관측된 데이터를 싹다 메모리에 넣어서 학습시키기에는 메모리가 딸릴때, 조금 더 효율적으로 사용한다는 의미도 있겠다.

"Online learning is helpful when the data may be changing rapidly over time. It is also useful for applications that involve a large collection of data that is constantly growing, even if changes are gradual."

— Page 753, Artificial Intelligence: A Modern Approach, 3rd edition, 2015.

일반적으로, Online learning은 "regret"을 최소화하려 든다.

아까 메모리가 딸릴 때, 효율적으로 사용한다고 했는데, 그럼 전체 데이터셋을 다 사용했을 때랑, 적당히 잘라서 썼을 때랑, 차이가 있을 텐데, 이걸 "regret"으로 표현하는듯.

"In the theoretical machine learning community, the objective used in online learning is the regret, which is the averaged loss incurred relative to the best we could have gotten in hindsight fixed parameter value."

— Page 262, Machine Learning: A Probabilistic Perspective, 2012.

13. Transfer Learning

Transfer Learning이란, A task dataset을 통해 모델을 학습시키고, 이 모델의 일부 또는 전체를 활용해 B task dataset을 학습시키는 것을 의미한다.

물론 이 때, A task와 B task는 어느 정도 연관있는게 맞겠지?

"In transfer learning, the learner must perform two or more different tasks, but we assume that many of the factors that explain the variations in P1 are relevant to the variations taht need to be captured for learning P2."

— Page 536, Deep Learning, 2016.

B task를 해결하는게 목적이지만, 여기에 데이터가 굉장히 부족한 상황. 그런데 유사한 A task에 대한 데이터셋은 풍부하다면, Transfer learning을 적용해볼만하겠다.

Multi-Task learning은 한번에 다양한 Task를 학습시킨다는 것에서 그 차이는 명확하지 뭐.

"… pretrain a deep convolutional net with 8 layers of weights on a set of tasks (a subset of the 1000 ImageNet object categories) and then initialize a same-size network with the first k layers of the first net. All the layers of the second network (with the upper layers initialized randomly) are then jointly trained to perform a different set of tasks (another subset of the 1000 ImageNet object categories), with fewer training examples than for the first set of tasks."

— Page 325, Deep Learning, 2016.

예를 들어, 이미지 분류를 시행할 때, 바로 고양이냐 개냐 따지는 데이터셋만 학습시키기 보다는, 그냥 아무런 ImageNet dataset 싹다 끌고와서 CNN 모델 학습시키고, 20개 예측하는 모델이랑 2개 분류하는 모델이랑 레이어 후반부가 달라야 맞으니까 그 파트만 적당히 바꿔치기하면 되는 거지.

특히 CNN은 Layer의 깊이에 따라 Low - High level의 feature를 학습하기 때문에, 충분히 합당한 생각.

"If there is significantly more data in the first setting (sampled from P1), then that may help to learn representations that are useful to quickly generalized from only very few examples drawn from P2. Many visual categories share low-level notions of edges and visual shapes, the effects of geometric changes, changes in lighting, etc."

— Page 536, Deep Learning, 2016.

14. Ensemble Learning

Ensemble Learning이란, 이미 아는 것처럼 2개 이상의 모델을 하나의 데이터셋을 통해 학습시키고, 이들을 조합해서 예측 결과를 내놓는 것.

그 조합을 우째 하느냐- 가 Ensemble 내부에서도 이슈겠다 그져잉~

"The field of ensemble learning provides many ways of combining the ensemble members' predictions, including uniform weighting and weights chosen on a validation set."

— Page 472, Deep Learning, 2016.

예시는 이미 아는 것 처럼, Stacking, Bagging 많고, NN 자체를 하나의 Ensemble model로 보는 시각도 있더라.


여기까지가 블로그 내용인데...

생각해보니 더 있어...

Federated Learning, Curriculum Learning, Confident Learning, Weakly Supervised Learning...

지친다... 왜래 많어...

Curriculum, Confident Learning은 나중에 기회가 되면 또 정리해보고...

꽤나 익숙한 Weakly Supervised Learning과...

요즘 좀 자주보이는... Federated Learning만 추가로 정리를 해보자...


Weakly Supervised Learning

별 거 없고... Supervised Learning으로 학습시켰는데,

레이블에 대한 정보 외에 다른 것까지도 학습되는 걸 의미.

Class Activation Mapping(CAM)이 가장 유명한데... Image segmentation...

CNN은 보통 Conv + FC 인데, 이거로 학습시킨 뒤에

FC 없애고 Conv feature map을 GAP 통과시켜

그 다음 이걸 FC 통과시키는데, 출력 차원은 클래스 개수...

그 다음 CAM을 계산하는데... FC 통과시켜서 얻은 Weight랑 Feature map들을 가중합시킨다...

이렇게하면, CNN이 사진의 어디를 보고 어떤 클래스로 예측했는지 확인 가능...


Federated Learning

개인적인 느낌은 Online Learning의 확장판...?

구글 AI 블로그 자료에서는, Federated Learning - 연합? 학습? 에 다음과 같은 부제를 달아놨다.

"Collaborative Machine Learning without Centralized Training Data" - 중앙 집중식 학습 데이터가 없는 협업 기계 학습

중앙 집중식? 그리고 협업? 이라는 키워드가 어떻게 해석되면 될지, 생각하며 정리해보자.

우선, 기존의 ML들이, 중앙 집중식 학습 데이터를 사용한다- 라는 말에 별다른 이견은 들지 않는다.

구체적으로, 구글은 자신들이 사용하는 다양한 서비스를 개선하기 위해, ML 모델을 사용하는데, 이들의 학습을 위해서, 수많은 데이터를, 자신들의 클라우드에 올려둘 수 있는 충분한 인프라를 구축해두었다.

그러나 음... 시리 따위를 생각해보자.

수 많은 개인 사용자가, 시리를 자신의 목소리로 사용하고, 이것은 학습데이터로 이용될 수 있다.

그런데, 이런 개인정보를 다시 중앙 서버로 옮겨두고 학습을 진행하려드는게 과연 합리적인가?

첫째로, 개인정보이기 때문에, 중앙 서버로 옮기는 것 자체에 제약이 있으며, 개인에 대한 정보를 마스킹하는 것은 그또한 정보의 손실, 학습률의 저하로 이어진다.

둘째로, 이런 데이터는 감당하기 힘들 정도로 많을 수 있다. 저장하는 것부터, 학습에 소요되는 시간까지, 리소스 잡아먹는 괴물이 될 수 있다.

이러한 문제를 해결하기 위해 제안되는 것이 Federated Learning. - 모바일 기기에서 자주 사용되는 삘링

Federated Learning에서는 학습 데이터를 굳이 중앙 서버로 옮기지 않는다. 사용자들의 모바일기기 - 휴대폰 따위 - 는 이미 학습된 모델을 다운로드하고, 개인 휴대폰에 있는 데이터를 활용하여 학습을 진행한다. 이후 "데이터 자체" 가 아닌, 모델의 "업데이트된 부분" - 구체적으로는 웨이트 따위일까? - 을 클라우드로 올려보낸다. 그리고 클라우드는 이런 다양한 업데이트 파트를 통합하여, 최종 모델을 업데이트한다.

그럼, 사용자는 개인 업데이트된 모델을 사용하는가? 아니면 클라우드로 업데이트된 모델을 사용하는가?

둘 다 쓰는듯. 여전히 클라우드로 업데이트된 모델은 즉각적으로 반응하기 쉽지 않다. 직접 학습을 시키지는 않지만 여러 값들을 종합하여 모델을 최신화시켜야하니.

일단 개별 업데이트 된 거 쓰다가, 클라우드 최신판 나오면 그거 또 받고 이런식.

쨋든 이런식으로 로컬에서 데이터를 사용한 학습을 진행하기 때문에, 개인정보에 대한 이슈도 없고, 리소스도 어느정도 로컬로 분산시킬 수 있기 때문에 이득.

추가로, 이런 학습방법을 진행할 때는 그냥 SGD를 못 써먹는단다.

SGD는 기본적으로 중앙 집중식 데이터가 정렬 잘 되있는 걸 기준으로 최적화가 되어있는데,

지금은 데이터가 여기저기 흩뿌려져있는데다, 각 데이터의 량도 불균형하니까, 고려할게 꽤나 많아진다.

래서 뭐 새로운 알고리즘 만들고 하는데 여기까지는 아직 자세히 안알아봐도 될 듯.