for hetero_lv in hetero_lv_list: LSGD_train_result_sub = [] LSGD_est_result_sub = [] LSGD_time_sub = [] lambda_param = 1e-2 / hetero_lv # Penalty parameter np.random.seed(111) beta_mu = np.random.normal(loc=0.0, scale=hetero_lv, size=M) # means of shift for each devices beta_true_list = [] # list of true local parameters for m in range(M): shift = np.random.uniform(beta_mu[m]-0.01, beta_mu[m]+0.01, size=d_gl) beta_true_list.append(w_true + shift) data_all = data_generate_fn(n, M, d_gl, beta_true_list) for i_repeat in range(n_repeat): # Parameters of LSGD_PFL avg_period = 5 w0 = np.zeros(d_gl) beta0_list = [] for m in range(M): beta0_list.append(np.zeros(d_gl)) eta_LSGD = 0.01 # train by LSGD_PFL start_time = time.time() print("hetero_lv: {} | Repeat: {} | Training by LSGD_PFL".format(hetero_lv, i_repeat+1)) loss_train_LSGD, loss_est_LSGD, w_LSGD, beta_list_LSGD = LSGD_PFL(data_all, loss_fun_MX2, fmj_grads_MX2, eta_LSGD, n_commun, avg_period, est_err_MX2, w_true, beta_true_list, w0, beta0_list,
start_time_total = time.time() for hetero_lv in hetero_lv_list: LSGD_train_result_sub = [] LSGD_est_result_sub = [] LSGD_time_sub = [] np.random.seed(111) beta_mu = np.random.normal(loc=0.0, scale=hetero_lv, size=M) # means of shift for each devices beta_true_list = [] # list of true local parameters for m in range(M): beta_true_list.append( np.random.uniform(beta_mu[m] - 0.01, beta_mu[m] + 0.01, size=d_l)) data_all = data_generate_fn(n, w_true, beta_true_list) for i_repeat in range(n_repeat): # Parameters of LSGD_PFL avg_period = 5 w0 = np.zeros(d_g) beta0_list = [] for m in range(M): beta0_list.append(np.zeros(d_l)) eta_LSGD = 0.01 # train by LSGD_PFL start_time = time.time() print("hetero_lv: {} | Repeat: {} | Training by LSGD_PFL".format( hetero_lv, i_repeat + 1)) loss_train_LSGD, loss_est_LSGD, w_LSGD, beta_list_LSGD = LSGD_PFL(