Comments (3)
@alexey-gruzdev, we do have some of this in place: I believe we interpret one of the flplan args as the aggregation function. If the name doesn't match our pre-defined strings, we assume it is a numpy function and invoke it.
I'd like the end-result to be the same as others: you can declare arbitrary python classes in the flplan that provide the functionality, along with init kwargs, the function to invoke, and kwargs for that function. Essentially, our same generic task declaration method we use for the collaborators. This is one of the reasons Patrick and I have been talking about making the aggregator essentially "just another task runner".
This would also have a nice advantage in that we wouldn't have to hard-code the logic that chooses which tensors are inputs for the aggregation function. Instead, it would use the same generic logic that determines the tensor input requirements for any task.
from openfl.
@msheller that's great, if we have it in place - could you provide a simple example for the reference?
Ideally, for better extendibility it would be great to have a python function to be passed to Python API entities & being used by OpenFL further.
def custom_aggregation(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
return (a + b)/2
fl_model = fx.run_experiment(collaborators, agg_function=custom_aggregation,
override_config={'aggregator.settings.rounds_to_train':5})
you can declare arbitrary python classes in the flplan that provide the functionality, along with init kwargs, the function to invoke, and kwargs for that function
Maybe I am wrong, however from Python user's perspective - is it a right place to define such kind of functionalities in FLPlan (.yaml)?
from openfl.
@alexey-gruzdev This is a feature I added a few months ago. A limited set of custom aggregation types are supported at the task level. They can be called in the following way:
plan.yaml
...
tasks:
aggregated_model_validation:
aggregation_type: median
function: validate
kwargs:
apply: global
batch_size: 32
metrics:
- accuracy
...
and you can call it through the current Python API like this:
fl_model = fx.run_experiment(collaborators, agg_function=custom_aggregation,
override_config={'aggregator.settings.rounds_to_train':5,
'tasks.aggregated_model_validation.aggregation_type': 'median'})
These aggregation types are currently limited to simple numpy functions (see here). As both of you suggest, we should provide a way to define custom functions that can be applied to model weights and task metrics. There is likely a need to apply a specific aggregation function to certain task output, and possibly another for how to combine model weights. Because of this level of specificity my view is that the plan is the appropriate place to embed this information, but we could extend our existing python APIs so that the user has a cleaner way for expressing the function they want to use without modifying the plan directly.
from openfl.
Related Issues (20)
- Keyboard focus order in expandable section at bottom of sidebar does not allow access to main content of page;
- No programmatic description of expandable elements in sidebar as being expandable, until/unless they are expanded HOT 1
- Mobile/compact menu does not behave like other ‘hamburger menus’ HOT 1
- Keyboard access to expandable sidebar menu items is non-standard HOT 1
- Expand/collapse controls are too small
- Suggest use of a bypass block (skip to main content link) HOT 1
- Suggest bypass blocks for long code blocks
- Disambiguate the permalinks so that they do not all have the same programmatic name HOT 1
- Overuse / misuse of 'block quote' style HOT 1
- Keyboard shortcuts are communicated to screenreader user but not sighted user
- Disambiguate the duplicate bolded captions for ‘federated learning’ graphics
- Code example uses image of text instead of text HOT 1
- Graphic with image of text also has text too small for average user to read
- Image of text should use text - ordered list in graphic
- Incorrect syntax / use for heading in sidebar HOT 1
- Contain all content in a given page within landmarks HOT 1
- When page is narrow enough to introduce a horizontal scrollbar, keyboard can’t be used to scroll code samples
- Create docstrings for all public functions and create OpenFL API Documentation HOT 1
- Create dependabot.yml config to only scan core dependencies
- Aggregator freezing with `gramine-sgx` for `torch_cnn_histology_gramine_ready`
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 openfl.