• bitcoinBitcoin(BTC)$77,151.000.52%
  • ethereumEthereum(ETH)$2,105.740.76%
  • tetherTether(USDT)$1.000.03%
  • binancecoinBNB(BNB)$661.211.11%
  • rippleXRP(XRP)$1.350.18%
  • usd-coinUSDC(USDC)$1.000.00%
  • solanaSolana(SOL)$84.81-0.20%
  • tronTRON(TRX)$0.3717291.86%
  • Figure HelocFigure Heloc(FIGR_HELOC)$1.030.00%
  • dogecoinDogecoin(DOGE)$0.1018430.17%
  • HyperliquidHyperliquid(HYPE)$61.44-1.38%
  • USDSUSDS(USDS)$1.00-0.01%
  • zcashZcash(ZEC)$650.05-1.90%
  • leo-tokenLEO Token(LEO)$9.99-0.55%
  • cardanoCardano(ADA)$0.2428660.77%
  • moneroMonero(XMR)$386.45-0.33%
  • bitcoin-cashBitcoin Cash(BCH)$349.120.97%
  • chainlinkChainlink(LINK)$9.470.77%
  • whitebitWhiteBIT Coin(WBT)$56.740.30%
  • CantonCanton(CC)$0.1663540.69%
  • the-open-networkToncoin(TON)$1.9410.46%
  • stellarStellar(XLM)$0.1495841.92%
  • USD1USD1(USD1)$1.00-0.05%
  • Ethena USDeEthena USDe(USDE)$1.000.05%
  • daiDai(DAI)$1.000.01%
  • suiSui(SUI)$1.041.22%
  • litecoinLitecoin(LTC)$52.53-0.07%
  • avalanche-2Avalanche(AVAX)$9.291.31%
  • RainRain(RAIN)$0.0080196.09%
  • MemeCoreMemeCore(M)$2.953.01%
  • hedera-hashgraphHedera(HBAR)$0.0880880.17%
  • paypal-usdPayPal USD(PYUSD)$1.00-0.03%
  • nearNEAR Protocol(NEAR)$2.7514.61%
  • shiba-inuShiba Inu(SHIB)$0.000006-0.20%
  • crypto-com-chainCronos(CRO)$0.0687380.04%
  • Circle USYCCircle USYC(USYC)$1.130.00%
  • Global DollarGlobal Dollar(USDG)$1.00-0.01%
  • tether-goldTether Gold(XAUT)$4,552.660.25%
  • BittensorBittensor(TAO)$280.012.39%
  • BlackRock USD Institutional Digital Liquidity FundBlackRock USD Institutional Digital Liquidity Fund(BUIDL)$1.000.00%
  • mantleMantle(MNT)$0.650.28%
  • pax-goldPAX Gold(PAXG)$4,559.980.18%
  • Ondo US Dollar YieldOndo US Dollar Yield(USDY)$1.130.40%
  • OndoOndo(ONDO)$0.4377290.74%
  • polkadotPolkadot(DOT)$1.261.73%
  • uniswapUniswap(UNI)$3.32-1.32%
  • World Liberty FinancialWorld Liberty Financial(WLFI)$0.0612890.77%
  • HTX DAOHTX DAO(HTX)$0.0000020.67%
  • AsterAster(ASTER)$0.69-1.41%
  • Falcon USDFalcon USD(USDF)$1.000.08%
TradePoint.io
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop
No Result
View All Result
TradePoint.io
No Result
View All Result

Step by Step Guide to Build and Compare FedAvg and FedProx Federated Learning on Non-IID CIFAR-10 with NVIDIA FLARE

May 25, 2026
in AI & Technology
Reading Time: 2 mins read
A A
Step by Step Guide to Build and Compare FedAvg and FedProx Federated Learning on Non-IID CIFAR-10 with NVIDIA FLARE
ShareShareShareShareShare

YOU MAY ALSO LIKE

Here’s The First Car From Jony Ive’s Design House

Why prompt debt, retrieval debt, and evaluation debt are quietly reshaping enterprise AI risk

CLIENT_SCRIPT += r'''
def main():
   p = argparse.ArgumentParser()
   p.add_argument("--num_sites", type=int, default=3)
   p.add_argument("--alpha", type=float, default=0.3)
   p.add_argument("--local_epochs", type=int, default=1)
   p.add_argument("--mu", type=float, default=0.0)
   p.add_argument("--max_samples", type=int, default=4000)
   p.add_argument("--batch_size", type=int, default=64)
   p.add_argument("--lr", type=float, default=0.01)
   p.add_argument("--data_root", type=str, default="/tmp/nvflare/data")
   p.add_argument("--results_dir", type=str, default="/tmp/nvflare/results")
   p.add_argument("--tag", type=str, default="fedavg")
   args = p.parse_args()
   device = "cuda" if torch.cuda.is_available() else "cpu"
   tf = T.Compose([T.ToTensor(),
                   T.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
   train_set = torchvision.datasets.CIFAR10(args.data_root, train=True,  download=False, transform=tf)
   test_set  = torchvision.datasets.CIFAR10(args.data_root, train=False, download=False, transform=tf)
   flare.init()
   site_name = flare.get_site_name()
   site_id   = int(site_name.split("-")[-1]) - 1
   labels   = np.array(train_set.targets)
   my_idx   = dirichlet_partition(labels, args.num_sites, args.alpha)[site_id]
   if len(my_idx) > args.max_samples:
       my_idx = my_idx[:args.max_samples]
   train_loader = DataLoader(Subset(train_set, my_idx), batch_size=args.batch_size, shuffle=True)
   test_loader  = DataLoader(test_set, batch_size=512, shuffle=False)
   print(f"[{site_name}] mu={args.mu}  local samples={len(my_idx)}", flush=True)
   model     = Net().to(device)
   optimizer = torch.optim.SGD(model.parameters(), lr=args.lr, momentum=0.9)
   criterion = nn.CrossEntropyLoss()
   while flare.is_running():
       input_model = flare.receive()
       rnd = input_model.current_round
       global_state = {k: torch.as_tensor(v) for k, v in input_model.params.items()}
       model.load_state_dict(global_state)
       acc = evaluate(model, test_loader, device)
       if site_id == 0:
           with open(os.path.join(args.results_dir, args.tag + ".csv"), "a", newline="") as f:
               csv.writer(f).writerow([rnd, acc])
       print(f"[{site_name}] round {rnd}: global test acc = {acc:.4f}", flush=True)
       global_w = [w.detach().clone() for w in model.parameters()]
       model.train()
       steps = 0
       for _ in range(args.local_epochs):
           for x, y in train_loader:
               x, y = x.to(device), y.to(device)
               optimizer.zero_grad()
               loss = criterion(model(x), y)
               if args.mu > 0:
                   prox = sum(((w - g) ** 2).sum() for w, g in zip(model.parameters(), global_w))
                   loss = loss + (args.mu / 2.0) * prox
               loss.backward()
               optimizer.step()
               steps += 1
       out = flare.FLModel(
           params={k: v.cpu().numpy() for k, v in model.state_dict().items()},
           metrics={"test_accuracy": acc},
           meta={"NUM_STEPS_CURRENT_ROUND": steps},
       )
       flare.send(out)
if __name__ == "__main__":
   main()
'''
with open("client_train.py", "w") as f:
   f.write(CLIENT_SCRIPT)
sys.path.insert(0, os.getcwd())
from client_train import Net

Credit: Source link

ShareTweetSendSharePin

Related Posts

Here’s The First Car From Jony Ive’s Design House
AI & Technology

Here’s The First Car From Jony Ive’s Design House

May 25, 2026
Why prompt debt, retrieval debt, and evaluation debt are quietly reshaping enterprise AI risk
AI & Technology

Why prompt debt, retrieval debt, and evaluation debt are quietly reshaping enterprise AI risk

May 25, 2026
Epic Games Reveals A First Look At Unreal Engine 6 With A Rocket League Makeover
AI & Technology

Epic Games Reveals A First Look At Unreal Engine 6 With A Rocket League Makeover

May 25, 2026
Star Citizen Has Raised  Billion, Remains In Early Access After Nine Years
AI & Technology

Star Citizen Has Raised $1 Billion, Remains In Early Access After Nine Years

May 25, 2026
Next Post
Avacta Group Plc (AVCTF) Q4 2025 Earnings Call Transcript

Avacta Group Plc (AVCTF) Q4 2025 Earnings Call Transcript

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

No Result
View All Result
Oil prices drop 5% after Trump says Iran talks are moving in ‘constructive’ direction

Oil prices drop 5% after Trump says Iran talks are moving in ‘constructive’ direction

May 25, 2026
Kore.ai launches Artemis AI agent platform, takes on Salesforce and ServiceNow

Kore.ai launches Artemis AI agent platform, takes on Salesforce and ServiceNow

May 21, 2026
Joanna Stern breaks down what we can expect from the new Apple CEO John Ternus

Joanna Stern breaks down what we can expect from the new Apple CEO John Ternus

May 20, 2026

About

Learn more

Our Services

Legal

Privacy Policy

Terms of Use

Bloggers

Learn more

Article Links

Contact

Advertise

Ask us anything

©2020- TradePoint.io - All rights reserved!

Tradepoint.io, being just a publishing and technology platform, is not a registered broker-dealer or investment adviser. So we do not provide investment advice. Rather, brokerage services are provided to clients of Tradepoint.io by independent SEC-registered broker-dealers and members of FINRA/SIPC. Every form of investing carries some risk and past performance is not a guarantee of future results. “Tradepoint.io“, “Instant Investing” and “My Trading Tools” are registered trademarks of Apperbuild, LLC.

This website is operated by Apperbuild, LLC. We have no link to any brokerage firm and we do not provide investment advice. Every information and resource we provide is solely for the education of our readers. © 2020 Apperbuild, LLC. All rights reserved.

No Result
View All Result
  • Main
  • AI & Technology
  • Stock Charts
  • Market & News
  • Business
  • Finance Tips
  • Trade Tube
  • Blog
  • Shop

© 2023 - TradePoint.io - All Rights Reserved!