Comments (8)
在flwr/server/server.py的代码里好像有地方可以修改,但是也需要改代码
from flower.
在flwr/server/server.py的代码里好像有地方可以修改,但是也需要改代码
是的,但是不知道怎么修改这个策略 ,现在我看都是一个固定值,没法和训练轮数挂钩。
我现在能想到的方法就是写两个模拟函数fl.simulation.start_simulation,比如前10epochs,客户端选择10个;后10个epochs训练再启动一个模拟函数,选择20个客户端,他的模型参数用第一次训练的参数。
from flower.
在flwr/server/server.py的代码里好像有地方可以修改,但是也需要改代码
是的,但是不知道怎么修改这个策略 ,现在我看都是一个固定值,没法和训练轮数挂钩。 我现在能想到的方法就是写两个模拟函数fl.simulation.start_simulation,比如前10epochs,客户端选择10个;后10个epochs训练再启动一个模拟函数,选择20个客户端,他的模型参数用第一次训练的参数。
感觉你这个方法也可以,或者你可以试试把fraction_fit这个值从某个配置文件(比如/opt/fraction_fit.txt)中读取,然后在训练10轮以后修改/opt/fraction_fit.txt的内容,然后server.py再去读取这个内容?我不太确定server的启动是不是每轮都会重新分配一下,你可以试试
from flower.
在flwr/server/server.py的代码里好像有地方可以修改,但是也需要改代码
是的,但是不知道怎么修改这个策略 ,现在我看都是一个固定值,没法和训练轮数挂钩。 我现在能想到的方法就是写两个模拟函数fl.simulation.start_simulation,比如前10epochs,客户端选择10个;后10个epochs训练再启动一个模拟函数,选择20个客户端,他的模型参数用第一次训练的参数。
感觉你这个方法也可以,或者你可以试试把fraction_fit这个值从某个配置文件(比如/opt/fraction_fit.txt)中读取,然后在训练10轮以后修改/opt/fraction_fit.txt的内容,然后server.py再去读取这个内容?我不太确定server的启动是不是每轮都会重新分配一下,你可以试试
好的我试一试,我刚刚看到一个参数on_fit_config_fn ,感觉可能解决这个问题
from flower.
在flwr/server/server.py的代码里好像有地方可以修改,但是也需要改代码
是的,但是不知道怎么修改这个策略 ,现在我看都是一个固定值,没法和训练轮数挂钩。 我现在能想到的方法就是写两个模拟函数fl.simulation.start_simulation,比如前10epochs,客户端选择10个;后10个epochs训练再启动一个模拟函数,选择20个客户端,他的模型参数用第一次训练的参数。
感觉你这个方法也可以,或者你可以试试把fraction_fit这个值从某个配置文件(比如/opt/fraction_fit.txt)中读取,然后在训练10轮以后修改/opt/fraction_fit.txt的内容,然后server.py再去读取这个内容?我不太确定server的启动是不是每轮都会重新分配一下,你可以试试
你使用flower框架是在做什么呢,我现在的研究方向是联邦学习的差分隐私
from flower.
我研究联邦学习的客户端选择策略
from flower.
Hi, this can be done by overriding the configure_fit
function of the strategy.
E.g.,
def configure_fit(
self, server_round: int, parameters: Parameters, client_manager: ClientManager
) -> List[Tuple[ClientProxy, FitIns]]:
"""Configure the next round of training."""
config = {}
if self.on_fit_config_fn is not None:
# Custom fit config function provided
config = self.on_fit_config_fn(server_round)
fit_ins = FitIns(parameters, config)
# Sample clients
sample_size, min_num_clients = self.num_fit_clients(
client_manager.num_available()
)
clients = client_manager.sample(
num_clients=sample_size, min_num_clients=min_num_clients
)
# Sample the clients sequentially given server_round
sampled_idx = (server_round - 1) % len(clients)
sampled_clients = [clients[sampled_idx]]
# Return client/config pairs
return [(client, fit_ins) for client in sampled_clients]
The above code allows to sequentially sample the clients given server_round
. You could do whatever clients sampling based on the given server_round
.
from flower.
Hi, this can be done by overriding the
configure_fit
function of the strategy. E.g.,def configure_fit( self, server_round: int, parameters: Parameters, client_manager: ClientManager ) -> List[Tuple[ClientProxy, FitIns]]: """Configure the next round of training.""" config = {} if self.on_fit_config_fn is not None: # Custom fit config function provided config = self.on_fit_config_fn(server_round) fit_ins = FitIns(parameters, config) # Sample clients sample_size, min_num_clients = self.num_fit_clients( client_manager.num_available() ) clients = client_manager.sample( num_clients=sample_size, min_num_clients=min_num_clients ) # Sample the clients sequentially given server_round sampled_idx = (server_round - 1) % len(clients) sampled_clients = [clients[sampled_idx]] # Return client/config pairs return [(client, fit_ins) for client in sampled_clients]
The above code allows to sequentially sample the clients given
server_round
. You could do whatever clients sampling based on the givenserver_round
.
"Thank you very much. Your answers have been very helpful to me."
from flower.
Related Issues (20)
- Fatal Python error: Aborted HOT 1
- How to Save Client Models and results After Each Round in Flower HOT 4
- How can the client send custom content messages to the server? HOT 3
- Division error in function “divide_dataset” HOT 2
- flwr_datasets with custom/local dataset HOT 1
- No Prometheus nor Grafana Plots - /examples/flower-via-docker-compose HOT 3
- Add Flower Baseline: FedPFT HOT 4
- Dynamic timeout settings
- Running flw baseline fedAVG_MNIST with recommended parameters on README gives accuracy better than the paper "best result" HOT 1
- Facing issue with Flower Simulation with ResNet18 and MNIST dataset HOT 3
- Out of Memory while learning on Cifar with 100 clients HOT 1
- macOS: pip install flwr[simulation] uninstalls flwr 1.8.0 and installs 0.16.0 HOT 6
- RayActorClientProxy.get_parameters() missing 1 required positional argument: 'group_id'
- How to let the client train using the initial model provided by the server?
- How to get consistent order of spawned clients between multiple runs with Flower's simulation?
- flutter support HOT 1
- how to show the full args in task page? HOT 1
- Perform strategy in the sampled clients and its subset at the same time
- Method Doesn't Exist HOT 3
- ConnectionError: Couldn't reach 'cifar10' on the Hub (ConnectionError)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flower.