INNER CODE UNIT · Python

norms

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

        norms = np.clip(norms, 1e-8, None)  # avoid zero
        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(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…