server.load_model_weights(weight_path) server.update_client_train_params(client_train_params) server.create_clients_plus() (x_train, y_train), (x_test, y_test) = datasets.fashion_mnist.load_data() x_train = x_train.astype("float32") / 255 x_test = x_test.astype("float32") / 255 # Make sure images have shape (28, 28, 1) x_train = np.expand_dims(x_train, -1) x_test = np.expand_dims(x_test, -1) data_handler = fed_learn.DataHandler(x_train, y_train, x_test, y_test, fed_learn.CifarProcessor(), args.debug) data_handler.assign_data_to_clients_plus(server.clients, args.data_sampling_technique) x_test, y_test = data_handler.preprocess(data_handler.x_test, data_handler.y_test) test_acc = 0.1 for epoch in range(args.global_epochs): print("Global Epoch {0} is starting".format(epoch)) server.init_for_new_epoch() selected_clients = server.select_clients() fed_learn.print_selected_clients(selected_clients) for client in selected_clients: print("Client {0} is starting the training".format(client.id)) server.send_model(client)
weight_summarizer = fed_learn.FedAvg() server = fed_learn.Server(model_fn, weight_summarizer, args.clients + 1, args.fraction) weight_path = args.weights_file if weight_path is not None: server.load_model_weights(weight_path) server.update_client_train_params(client_train_params) #create the n+1 th device server.create_clients_plus() (x_train, y_train), (x_test, y_test) = datasets.cifar10.load_data() data_handler = fed_learn.DataHandler(x_train, y_train, x_test, y_test, fed_learn.CifarProcessor(), args.debug) data_handler.assign_data_to_clients_plus(server.clients, args.data_sampling_technique, 0.01) x_test, y_test = data_handler.preprocess(data_handler.x_test, data_handler.y_test) test_acc = 0.1 for epoch in range(args.global_epochs): print("Global Epoch {0} is starting".format(epoch)) server.init_for_new_epoch() selected_clients = server.select_clients() fed_learn.print_selected_clients(selected_clients) for client in selected_clients: print("Client {0} is starting the training".format(client.id))