def fed_learn_exp(): module = leap_functions.fl_fn selector = "[age] > 50 and [bmi] < 25" leap_fed_learn = leap_fn.FedLearnFunction() leap_fed_learn.selector = selector leap_fed_learn.get_model = module.get_model leap_fed_learn.get_optimizer = module.get_optimizer leap_fed_learn.get_criterion = module.get_criterion leap_fed_learn.get_dataloader = module.get_dataloader hyperparams = { "lr": 1e-5, "d_x": 2, # input dimension "d_y": 1, # output dimension "batch_size": 1, "max_iters": 7, "iters_per_epoch":1 } leap_fed_learn.hyperparams = hyperparams return leap_fed_learn
def fed_learn_exp(): module = leap_functions.fl_fn selector = { "type": codes.DEFAULT, "useLocalData": True } leap_fed_learn = leap_fn.FedLearnFunction() leap_fed_learn.selector = selector leap_fed_learn.get_model = module.get_model leap_fed_learn.get_optimizer = module.get_optimizer leap_fed_learn.get_criterion = module.get_criterion leap_fed_learn.get_dataloader = module.get_dataloader hyperparams = { "lr": 1e-5, "d_x": 2, # input dimension "d_y": 1, # output dimension "batch_size": 1, "max_iters": 7, "iters_per_epoch":1 } leap_fed_learn.hyperparams = hyperparams return leap_fed_learn
import pickle import api.leap as leap import api.register.user.registration as user_reg import api.leap_fn as leap_fn import api.codes as codes import api.local.functions as leap_functions import random import argparse import numpy as np if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('num_sites', metavar='n', type=int) args = parser.parse_args() leap_fed_learn = leap_fn.FedLearnFunction() selector = {"type": codes.DEFAULT, "useLocalData": True} leap_fed_learn.selector = selector module = leap_functions.log_reg leap_fed_learn.get_model = module.get_model leap_fed_learn.get_optimizer = module.get_optimizer leap_fed_learn.get_criterion = module.get_criterion leap_fed_learn.get_dataloader = module.get_dataloader random.seed(1) ids = list(range(1, 10001)) random_ids = random.sample(ids, 10000) train_ids = random_ids[:8000]