securefederatedai / openfl

An open framework for Federated Learning.

Home Page:https://openfl.readthedocs.io/en/latest/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to send two separated data to two different collaborators?

amin-kaveh opened this issue · comments

Discussed in #778

Originally posted by amin-kaveh March 27, 2023
Hi,

I am new in federated learning and openfl. I have two separated (let's call them private) datasets and I want to send them to each collaborators separately. When I review tutorials, it seems that FederatedDataSet gets all the data together and split them into multiple sets and then FederatedModel function sends the same model and splits of data to each collaborators.

This is the code that have have from tutorials:

fl_data = FederatedDataSet(train_data, train_labels, valid_data, valid_labels, batch_size, num_classes)
fl_model = FederatedModel(build_model, optimizer, loss_fn, data_loader= fl_data)

But suppose I have private data that I want to sent to each collaborators:
data for collaborator 1: train_data_1, train_label_1, valid_data_1, valid_label_1
data for collaborator 2: train_data_2, train_label_2, valid_data_2, valid_label_2

Now, I want to send the model and data to each collaborators separately and then train them. Something like this:

send(build_model, train_data_1, train_label_1, valid_data_1, valid_label_1, to_collaborator_1 )
send(build_model, train_data_2, train_label_2, valid_data_2, valid_label_2, to_collaborator_2 )

And then start training them.
What are those commands and how can I train the model?

I really appreciate any help and insight.