티끌모아 태산

What is Federated learning 본문

AI

What is Federated learning

goldpig 2023. 11. 7. 16:36
728x90

  이번시간에는 Federated learning(연합 학습)이 무엇인지 그리고 관련된 프레임 워크 등에 대해서 알아보겠습니다. IoT(internet of thing) 기기가 증가함에 따라 smart city, healthcare, Internet of vehicles 등 다양한 분야에서 빅데이터가 생성되고 있습니다. 그래서 이러한 빅데이터를 효율적으로 처리하고 분석하기 위한 Deep Neural Network(DNN)에 대한 응용 연구가 활발히 진행되고 있습니다. 

 

  하지만 IoT 기기에서 생성되는 데이터에는 개인정보와 관련된 민감한 정보를 포함되어 있기 때문에 centralized machine learning 하는데는 위험 가능성이 존재합니다. 그래서 IoT 기기에서 발생하는 데이터를 서버로 보내서 학습하기 보다는 local 즉, edge device에서 직접 train 한 후 서버에 보내는 방안인 Federated Learning이 제안되었습니다. 즉, FL분산된 데이터 환경에서 모델을 학습하는 machine learning 방법론으로, 개인 사용자들이 중앙 서버에 모든 데이터를 전송하지 않고, 클라이언트 기기에서 데이터를 보유한 채로 모델을 local training한 후, 중앙 서버, 즉 global aggregator에 업데이트하는 방식으로 작동합니다.

Federated learning in five steps

  연합 학습은 다음과 같이 5단계를 거쳐서 진행됩니다.

  • 글로벌 모델 즉, 서버에서 모델을 초기화합니다. -> Initialize global model

출처: https://flower.dev/docs/framework/tutorial-series-what-is-federated-learning.html

  • 그 다음 모델을 여러 클라이언트(edge devices)에게 보냅니다. 
      Send the parameters of the global model to the connected client nodes (think: edge devices like smartphones or servers belonging to organizations). 즉, 모든 클라이언트들에게 same global model을 보냅니다. 그러면 모든 클라이언트는 같은 모델을 학습하게 됩니다. 그리고 We often use only a few of the connected nodes instead of all nodes. 왜냐하면 선택된 클라이언트의 수가 높아질 수록 반환값은 줄어들기 때문입니다.

출처: https://flower.dev/docs/framework/tutorial-series-what-is-federated-learning.html

  • 각 클라이언트는 로컬 데이터를 통해 서버로 부터 받은 모델을 학습합니다.
      Now that all (selected) client nodes have the latest version of the global model parameters, they start the local training. They use their own local dataset to train their own local model. 이때, 각 클라이언트는 Full convergence 할 때까지 학습하지 않고 일정 시간동안만 수행합니다. ❗️그렇게 함으로써 서버는 참여한 모든 클라이언트들로부터 model을 받아 global model을 업데이트할 수 있기 때문입니다. 

출처: https://flower.dev/docs/framework/tutorial-series-what-is-federated-learning.html

  • 각 로컬에서 클라이언트들이 학습을 완료하면 새로운 버전의 모델이 만들어지는데, 이를 서버에 보냅니다.
      After local training, each client node has a slightly different version of the model parameters they originally received. The parameters are all different because each client node has different examples in its local dataset. 그리고 이때 서버에게 보내지는 모델은 full model parameter or gradient that were accumulated during local training. 입니다. 왜냐하면 각 edge device마다 하드웨어가 달라 학습 능력에 차이가 있기 때문입니다.

출처: https://flower.dev/docs/framework/tutorial-series-what-is-federated-learning.html

  • 서버는 이렇게 새롭게 업데이트된 모델을 취합해서 새로운 버전의 글로벌 모델로 업데이트 합니다. 
      그러면 여러 클라이언트들로부터 받은 모델을 어떻게 하나의 모델로 업데이트 할까요? 가장 기본적인 방법이 Federated Average 방식입니다. 그리고 좀 더 정확하게 말하면 서버는 업데이트된 모델 자체를 받는것이 아니라 평균 가중치 값을 취합해서 글로벌 모델을 업데이트 합니다. (To be more precise, it takes the weighted average of the model updates, weighted by the number of examples each client used for training.) 가중치 값을 받아서 하는 이유는 새로운 글로벌 모델을 업데이트할 때 각 클라이언트가 똑같은 영향력을 미치기 위해서 입니다. (The weighting is important to make sure that each data example has the same “influence” on the resulting global model. If one client has 10 examples, and another client has 100 examples, then - without weighting - each of the 10 examples would influence the global model ten times as much as each of the 100 examples.) 즉, 가중치를 고려하지 않는다면 클라이언트 마다 갖고있는 examples수가 다르기 때문에 차등된 영향력을 미칩니다.

출처: https://flower.dev/docs/framework/tutorial-series-what-is-federated-learning.html

  • 이제 위 과정을 모든 클라이언트가 수렴할 때까지 반복합니다.
      위에서 설명했듯이 모든 클라이언트는 full convergence 할 때까지 train 하지 않고 일정 기간동안 수행한 후 full-parameter or gradient 를 서버에 보냅니다. 그러한 이유는 모든 클라이언트가 새로운 글로벌 모델에 영향을 미치기 위해서 입니다. (We then have to repeat this training process over and over again to eventually arrive at a fully trained model that performs well across the data of all client nodes.)

  지금까지 FD가 무엇인지 그리고 어떻게 작동하는지 대략적으로 알아보았습니다. 이를 응용한 그리고 한계점을 고려하여 나온 fedDCT 모델 등도 있습니다. 이는 Federated model이 각 클라이언트마다 다른 하드웨어를 고려하지 않았다는 문제점을 해결하기 위해 제시된 모델입니다. 그럼 이제 이와 관련된 프레임워크에 대해서 알아보겠습니다.

Federated Learning Framework - Flower

  In short, Flower presents a unified approach to federated learning, analytics, and evaluation. 즉 간략하게 플라워 프레임워크는 연합 학습, 분석, 평가를 한번에 할 수 있는 방식을 제공합니다. 그리고 이 프레임워크는 서버로부터 받은 모델을 학습하는 클라이언트들이 병렬로 학습할 수 있도록 구현되었습니다.

 

GitHub - adap/flower: Flower: A Friendly Federated Learning Framework

Flower: A Friendly Federated Learning Framework. Contribute to adap/flower development by creating an account on GitHub.

github.com

출처: https://flower.dev/docs/framework/tutorial-series-what-is-federated-learning.html

Get started with Flower

Flower에 대해 알아보기 위해서 다음링크에서 제공하는 튜터리얼을 진행해보면 좋을거 같습니다.

https://flower.dev/docs/framework/tutorial-series-get-started-with-flower-pytorch.html

 

Flower Framework main

Previous What is Federated Learning?

flower.dev

 

728x90

'AI' 카테고리의 다른 글

AI 기능 탑재한 '갤럭시 S24'  (1) 2024.01.21
온디바이스 AI  (0) 2024.01.20
AI 트렌드  (0) 2024.01.17