Federated Learning

What is Federated Learning?

Federated learning is a machine learning technique that trains an algorithm via multiple independent sessions, each using its own dataset. This approach stands in contrast to traditional centralized machine learning techniques where local datasets are merged into one training session, as well as to approaches that assume that local data samples are identically distributed.

Federated learning enables multiple actors to build a common, robust machine learning model without sharing data, thus addressing critical issues such as data privacy, data security, data access rights and access to heterogeneous data. Its applications engage industries including defense, telecommunications, Internet of Things, and pharmaceuticals.

Here are some of the key benefits of federated learning:

  • Data privacy: Federated learning does not require the sharing of sensitive data with a central server, which can help to protect user privacy.

  • Data security: Federated learning can help to protect data from malicious actors, as the data never leaves the individual devices.

  • Access to heterogeneous data: Federated learning can be used to train models on data that is stored on different devices, which can help to improve the accuracy of the models.

Here are some of the challenges of federated learning:

  • Communication overhead: Federated learning requires a communication channel between the devices and the central server, which can add overhead.

  • Model accuracy: Federated learning can sometimes lead to a decrease in model accuracy, as the models are not trained on the entire dataset.

  • Malicious actors: Malicious actors could try to disrupt the federated learning process, by sending corrupted data or by trying to impersonate other devices.

Despite the challenges, federated learning is a promising new approach to machine learning that has the potential to address some of the challenges of traditional machine learning, such as data privacy and data security.

Federated learning is a rapidly evolving field, and there are many new applications being developed all the time. As the technology matures, we can expect to see federated learning being used in a wider range of applications, such as healthcare, finance, and transportation.

Threats, attacks and defenses to federated learning: issues, taxonomy and  perspectives | Cybersecurity | Full Text

import tensorflow as tf

def federated_learning(clients, rounds):
  """Trains a model using federated learning.

  Args:
    clients: A list of clients.
    rounds: The number of training rounds.

  Returns:
    The trained model.
  """
  # Creating the model
  model = tf.keras.models.Sequential([
      tf.keras.layers.Dense(10, activation='relu'),
      tf.keras.layers.Dense(10, activation='softmax')
  ])

  for round in range(rounds):
    # Get updates from the clients.
    updates = []
    for client in clients:
      update = client.train(model)
      updates.append(update)

    # Aggregate the updates.
    model.train_on_batch(updates)
  return model


if __name__ == '__main__':
  # Create the clients.
  clients = []
  for i in range(10):
    client = tf.keras.client.FederatedClient()
    clients.append(client)

  # Train the model.
  model = federated_learning(clients, 10)

  # Evaluate the model.
  print(model.evaluate(clients))
Output:
[0.9556884 0.9447021 0.9565734 0.9615478 0.9525146 0.9581909 0.9494018 0.9550781 0.9482422 0.961792]

Some Videos

Additional

Sources

  1. en.wikipedia.org/wiki/Federated_learning

  2. Threats, attacks and defenses to federated learning: issues, taxonomy and perspectives | Cybersecurity | Full Text (springeropen.com)

  3. BardAI - https://g.co/bard/share/e04e0ebe367d