Supervised Learning

Supervised Learning with FedDDL

This guide shows you how to set up a supervised learning workload on FedDDL. You only need to provide a model, dataset arrays, and a few training hyperparameters; the platform handles client partitioning, rounds, and aggregation.

Learn by doing?

See a full example of MNist running on the Obit network here!

What you need to provide

  • Model architecture: a compiled tf.Sequential (or similar) model. Optimizers are supported; custom losses/metrics are not (use built-in Tensorflow.js losses/metrics).

  • Flattened dataset: input and output arrays sized to TOTAL_SAMPLES * INPUT_SIZE and TOTAL_SAMPLES * OUTPUT_SIZE respectively. Labels should already be encoded (e.g., one-hot for classification).

  • Test split (optional): testInput and testOutput arrays for evaluation.

  • Training config: TOTAL_SAMPLES, INPUT_SIZE, OUTPUT_SIZE, TOTAL_ROUNDS, BATCH_SIZE, EPOCHS_PER_ROUND, MIN_CLIENTS_TO_START.

Core class: SupervisedTrainingSession

Create one session per workload. It:

Constructor signature:

Minimal example

Data shape and partitioning

  • Data is partitioned per client by slicing the flat arrays; ensure arrays are contiguous and sized correctly.

  • input length must equal TOTAL_SAMPLES * INPUT_SIZE.

  • output length must equal TOTAL_SAMPLES * OUTPUT_SIZE (use one-hot labels for classification).

Constraints and tips

  • Avoid custom loss/metric functions; use built-in Tensorflow.js losses/metrics.

  • Metrics function is optional and runs on the server. Keep it lightweight to avoid logging overhead.

  • Choose BATCH_SIZE and EPOCHS_PER_ROUND based on requirements of your model. Larger values increase compute required for clients.

What runs where

  • The server hosts the session, partitions data, and aggregates weight segments.

  • The client receives its data partition and trains the model.

Last updated