联邦学习fate框架入门

1.拉取镜像

docker pull federatedai/standalone_fate:1.7.0

2.启动容器

docker run -d -it --name fate -p 8080:8080 federatedai/standalone_fate:1.7.0 /bin/bash

3.进入容器

docker exec -it fate /bin/bash

4.训练模型

4.1准备一份csv文件

也可以用容器内的样例数据,目录在/data/projects/fate/examples/data,这里以样例数据motor_hetero_guest.csv,motor_hetero_host.csv举例

4.2准备上传的配置文件

/data/projects/fate/fateflow/python/fate_flow/data/motor_hetero_guest.json

{
  "file": "/data/projects/fate/examples/data/motor_hetero_guest.csv",
  "head": 1,
  "partition": 16,
  "namespace": "experiment",
  "table_name": "motor_hetero_guest"
}

/data/projects/fate/fateflow/python/fate_flow/data/motor_hetero_host.json

{
  "file": "/data/projects/fate/examples/data/motor_hetero_host.csv",
  "head": 1,
  "partition": 16,
  "namespace": "experiment",
  "table_name": "motor_hetero_host"
}

4.3上传数据

cd /data/projects/fate/fateflow/python/fate_flow

python fate_flow_client.py -f upload -c data/motor_hetero_guest.json

python fate_flow_client.py -f upload -c data/motor_hetero_host.json

4.4模型训练

cd /data/projects/fate/examples/dsl/v2/hetero_linear_regression

flow job submit -c test_hetero_linr_train_job_conf.json -d test_hetero_linr_train_job_dsl.json 

此时记录控制台打印的模型id与模型版本,如对模型满意则需要模型部署发布出去

{
    "data": {
        "board_url": "http://127.0.0.1:8080/index.html#/dashboard?job_id=202210200319254001810&role=guest&party_id=9999",
        "code": 0,
        "dsl_path": "/data/projects/fate/fateflow/jobs/202210200319254001810/job_dsl.json",
        "job_id": "202210200319254001810",
        "logs_directory": "/data/projects/fate/fateflow/logs/202210200319254001810",
        "message": "success",
        "model_info": {
            "model_id": "arbiter-10000#guest-9999#host-10000#model",
            "model_version": "202210200319254001810"
        },
        "pipeline_dsl_path": "/data/projects/fate/fateflow/jobs/202210200319254001810/pipeline_dsl.json",
        "runtime_conf_on_party_path": "/data/projects/fate/fateflow/jobs/202210200319254001810/guest/9999/job_runtime_on_party_conf.json",
        "runtime_conf_path": "/data/projects/fate/fateflow/jobs/202210200319254001810/job_runtime_conf.json",
        "train_runtime_conf_path": "/data/projects/fate/fateflow/jobs/202210200319254001810/train_runtime_conf.json"
    },
    "jobId": "202210200319254001810",
    "retcode": 0,
    "retmsg": "success"
}

5.模型部署

flow model deploy --model-id arbiter-10000#guest-9999#host-10000#model --model-version 202210200319254001810

6.推理

6.1修改推理文件的模型id与模型版本为发布的,否则会失败,加载不到模型

联邦学习fate框架入门_第1张图片

6.2推理

flow job submit -c test_hetero_linr_predict_job_conf.json -d test_hetero_linr_predict_job_dsl.json

7.FATEBoard页面如下

从上到下三个任务分别是推理、训练、加载数据
联邦学习fate框架入门_第2张图片

你可能感兴趣的:(python,json,开发语言)