INNER CODE UNIT · Python

probs

Tisha-runwal/Personalized-Federated-Learning-for-Privacy--Preserving-and-Scalable-IoT-Driven-Smart-Healthcare · pfl_hcare/fl/server.py:384

        probs = norms / norms.sum()
        n_sample = min(n_to_sample, len(candidates))
        sampled_idx = rng.choice(len(candidates), size=n_sample, replace=False, p=probs)
        selected = forced + [candidates[i] for i in sampled_idx]
    else:
        selected = forced[:n_select] if len(forced) > n_select else forced

    # Ensure at least 2 clients
    if len(selected) < 2:
        remaining = [c for c in range(num_clients) if c not in selected]
        while len(selected) < min(2, num_clients) and remaining:
            selected.append(remaining.pop(0))

    return selected


def _record_round_metrics(
    mc, rnd, method, num_clients, selected_ids, fit_results,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…