easyfl-ai / easyfl Goto Github PK
View Code? Open in Web Editor NEWAn easy-to-use federated learning platform
License: Apache License 2.0
An easy-to-use federated learning platform
License: Apache License 2.0
` # fine-tune model
if args.use_MLP:
logreg = MLP(num_features, n_classes, 4096)
logreg = logreg.to(device)
else:
logreg = nn.Sequential(nn.Linear(num_features, n_classes))
logreg = logreg.to(device)
# loss / optimizer
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(params=logreg.parameters(), lr=args.learning_rate)
# Train fine-tuned model
logreg.train()
resnet.train()
accs = []
for epoch in range(args.num_epochs):
print("======epoch {}======".format(epoch))
metrics = defaultdict(list)
for step, (h, y) in enumerate(train_loader):
h = h.to(device)
y = y.to(device)
outputs = logreg(resnet(h))
loss = criterion(outputs, y)
optimizer.zero_grad()
loss.backward()
optimizer.step()
# calculate accuracy and save metrics
accuracy = (outputs.argmax(1) == y).sum().item() / y.size(0)
metrics["Loss/train"].append(loss.item())
metrics["Accuracy/train"].append(accuracy)
print(f"Epoch [{epoch}/{args.num_epochs}]: " + "\t".join(
[f"{k}: {np.array(v).mean()}" for k, v in metrics.items()]))
if epoch % 1 == 0:
acc = test_whole(resnet, logreg, device, test_loader, args.model_path)
if epoch <= 100:
accs.append(acc)
test_whole(resnet, logreg, device, test_loader, args.model_path)
print(args.model_path)
print(f"Best one for 100 epoch is {max(accs):.4f}")`
I have a question about the semi_supervised_evaluation.py script in FedSSL. During the finetuning process, the parameters of the Adam optimizer are set as logreg.parameters(). Does this mean that during finetuning, the parameters of the encoder won't be changed, and only the logreg model will be trained? Is this correct?
Will it support tabular data?
Is it possible to apply this FL architecture in transformer model?
Hi, I am so impressed with your EasyFL framework and related projects. Do you have a timeline for posting other projects? Thanks!
great works!!Can I use the dataset for object detection and how should I modify the configuration?
Hi,
I read the configuration file that supports the common DL models. But I have some customized models and non-public datasets as well (for classifying images) and need to use them within this awesome platform. How to apply that?
Thank you for your great work!
While I was able to successfully execute the experiments, I encountered a slight discrepancy in the accuracy results. Specifically, I achieved an accuracy of 82.1%, which is slightly lower than the 83.34% reported in the paper.
I want to know ae there any specific environmental or dependency versions that are critical to achieving the reported accuracy?
Hi, Thanks for the good work and open source of EasyFL. I am interested in your recent work discussing the SSL + FL.
When I run the FedSSL, I found a bug regarding the GPU runtime.
Specifically, when set up "--gpu 1", it will never use the current GPU. It is caused by the if-condition if args.gpu > 1
in main.py
, which will make the self.conf.gpu==0
all the time.
What I revise to make it work:
if args.gpu > 1
: config["gpu"] = args.gpu
self.conf.device = "cuda"
when self.conf.gpu==1
in coordinator.py
BTW, slurm is used for multiple GPU runtime. For those envs not using slurm, I recommend adding some warnings in the code or tutorial to make the multi-GPU configuration clear.
Hope it will help. Thanks for your work.
How can I declare model heterogeneous clients? And train another model in the server: )
aggregation_stragtegy: "FedAvg"
Hello, I want to use gpu speed up the training process. However the default gpu which id is "0" has been occupied. So I want to specify the gpu to train my model. But in the config file I only find the key that specify the number of gpu. So I want to know how to change the config file that I can specify my training gpu id.
Thanks for the excellent code, I have the following questions:
Where should I contribute (add) my code if I want to implement federated learning with limited resources. For example, I need to simulate the delay and energy consumption of weight upload, as well as the distribution of data in each edge node, training delay and energy consumption, etc. In order to achieve the above, I need to add functions, such as increasing the heterogeneity settings of clients, or realizing the bandwidth and network gain of transmission links.
Unfortunately, I don't see a way to do it in the existing code, and it seems that the above simulation is difficult to achieve. How should I insert it?
Hi, I am trying Easyfl but faced some issues with plotting loss graph. is there any supporting material about it?
Thank you for your good job ! I have a question on how to use it. In the paer "EasyFL: A Low-code Federated Learning Platform For Dummies" it is mentioned that Easyfl offers both qualitatively and quantitavely metrices. However, how can I read model accuracy, total training time, processing time each round?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.