Skip to content

Instantly share code, notes, and snippets.

@oglok
Created August 19, 2021 10:45
Show Gist options
  • Select an option

  • Save oglok/45945f46e242fd06cc09df1a959dd5f5 to your computer and use it in GitHub Desktop.

Select an option

Save oglok/45945f46e242fd06cc09df1a959dd5f5 to your computer and use it in GitHub Desktop.
Federated Learning Library Example
# First we have to use the library to generate data sets. NOTE: it's all based on the default examples.
root@4bf328b1096a:/app# python examples/generate_data.py -n 2 -d nursery -pp 200
Using TensorFlow backend.
Finished! :) Data saved in examples/data/nursery/random
# Once data is generated, we need the config files (YAML) for aggregator and N number of parties
root@4bf328b1096a:/app# python examples/generate_configs.py -n 2 -f id3_dt -d nursery -p examples/data/nursery/random/
Using TensorFlow backend.
Finished generating config file for aggregator. Files can be found in: /app/examples/configs/id3_dt/config_agg.yml
Finished generating config file for parties. Files can be found in: /app/examples/configs/id3_dt/config_party*.yml
# Now, in separate terminals, we need to run the aggregator and the parties. Let's just do one party for now:
############### AGGREGATOR ######################3
root@4bf328b1096a:/app# python -m ibmfl.aggregator.aggregator /app/examples/configs/id3_dt/config_agg.yml
2021-08-18 15:55:56,224 | 1.0.5 | INFO | ibmfl.util.config | Getting details from config file.
Using TensorFlow backend.
2021-08-18 15:55:58,125 | 1.0.5 | INFO | ibmfl.util.config | No metrics recorder config provided for this setup.
2021-08-18 15:55:58,258 | 1.0.5 | INFO | ibmfl.util.config | No data config provided for this setup.
2021-08-18 15:55:58,258 | 1.0.5 | INFO | ibmfl.util.data_handlers.nursery_data_handler | Loaded training data from examples/datasets/nursery.data
2021-08-18 15:55:58,286 | 1.0.5 | WARNING | ibmfl.util.data_handlers.nursery_data_handler | Column name missing. Adding default column names...
2021-08-18 15:55:58,289 | 1.0.5 | INFO | ibmfl.connection.flask_connection | RestSender initialized
2021-08-18 15:55:58,290 | 1.0.5 | INFO | ibmfl.aggregator.protohandler.proto_handler | State: States.START
2021-08-18 15:55:58,290 | 1.0.5 | INFO | ibmfl.connection.flask_connection | Receiver Initialized
2021-08-18 15:55:58,291 | 1.0.5 | INFO | ibmfl.connection.flask_connection | Initializing Flask application
2021-08-18 15:55:58,298 | 1.0.5 | INFO | __main__ | Aggregator initialization successful
############### PARTY ######################
root@4bf328b1096a:/app# python -m ibmfl.party.party /app/examples/configs/id3_dt/config_party0.yml
2021-08-18 15:56:11,112 | 1.0.5 | INFO | ibmfl.util.config | Getting config from file
2021-08-18 15:56:11,112 | 1.0.5 | INFO | ibmfl.util.config | Getting details from config file.
Using TensorFlow backend.
2021-08-18 15:56:13,105 | 1.0.5 | INFO | ibmfl.util.config | No metrics recorder config provided for this setup.
2021-08-18 15:56:13,238 | 1.0.5 | INFO | ibmfl.util.config | No data config provided for this setup.
2021-08-18 15:56:13,239 | 1.0.5 | INFO | ibmfl.util.data_handlers.nursery_data_handler | Loaded training data from examples/data/nursery/random/data_party0.csv
2021-08-18 15:56:13,249 | 1.0.5 | INFO | ibmfl.connection.flask_connection | RestSender initialized
2021-08-18 15:56:13,257 | 1.0.5 | INFO | ibmfl.connection.flask_connection | Receiver Initialized
2021-08-18 15:56:13,257 | 1.0.5 | INFO | ibmfl.connection.flask_connection | Initializing Flask application
2021-08-18 15:56:13,262 | 1.0.5 | INFO | __main__ | Party initialization successful
# Now, both entities are ready to accept commands, these are some of the commands:
AGGREGATOR: START, TRAIN, SYNC, SAVE, ....
PARTY: START, REGISTER, EVAL, ....
https://github.com/IBM/federated-learning-lib/tree/main/examples#ibm-fl-command-reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment