Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples of implementing HEU in the framework of federal learning #1034

Open
AustinApple opened this issue Nov 17, 2023 · 3 comments
Open

Examples of implementing HEU in the framework of federal learning #1034

AustinApple opened this issue Nov 17, 2023 · 3 comments
Assignees

Comments

@AustinApple
Copy link

AustinApple commented Nov 17, 2023

Issue Type

Others

Source

binary

Secretflow Version

SecretFlow 1.2.0.dev20231009

OS Platform and Distribution

macOS 13.2.1 (22D68)

Python version

Python 3.8.18

Bazel version

No response

GCC/Compiler version

No response

What happend and What you expected to happen.

Are there any examples of implementing HEU in the framework of federal learning?
@ian-huu
Copy link
Member

ian-huu commented Nov 20, 2023

@AustinApple
Copy link
Author

Thank you for the response. I am wondering how to implement HEU in the FLModel() class. For example, the following is my original code. I wanna use encrypted input to train the model, but I find that fit() function does not support heus argument.

heu = sf.HEU(heu_config('charlie', ['alice', 'bob']), spu.spu_pb2.FM128)
aggregator = SecureAggregator(server, [alice, bob])

fl_model = FLModel(
    server=server,
    device_list=device_list,
    model=model_def,
    aggregator=aggregator,
    strategy='fed_avg_w',
    backend="torch"
)
history = fl_model.fit(
    train_x,
    train_y,
    validation_data=(val_x, val_y),
    epochs=1,
    batch_size=128,
    aggregate_freq=1,
)

@ian-huu
Copy link
Member

ian-huu commented Nov 21, 2023

If you want to use HEU for aggregation, you can write a custom aggregator (you can refer to https://github.com/secretflow/secretflow/blob/main/secretflow/security/aggregation/spu_aggregator.py ).
If you want to use HEU for other purposes, you may need to inherit or even rewrite FLModel to achieve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants