TyXe-BDL / TyXe

MIT License
144 stars 33 forks source link

Way to open parameters #10

Open JonOnEarth opened 2 years ago

JonOnEarth commented 2 years ago

Hi, Recently I am doing some work in BNN for federated learning, found this nice work(TyXe) for BNN. Is there a way that TyXe can open the parameters of BNN and then we can do some aggregation among several BNNs.

For example, if we can get the BNN1 weight as Gaussian G(mean1, variance1), another BNN2 G(mean2, variance2). We can aggregate as two gaussian fusion.

really want to use and cite this code if possible. Thanks.

hpplyt commented 2 years ago

Yes that should be possible. The easiest way of accessing parameters would be through pyro's parameter store, i.e. just call pyro.get_param_store(). This gives you a global key-value mapping where all parameters live.

Just be aware that if you instantiate multiple BNN objects you will need to use the name argument in the init function for the BNNs to avoid name clashes (we should mention that in the docs, thanks for bringing it up!). Let me know if you encounter any issues, I haven't tested that use case before, but would expect things to work.