[BUG] Unable to define the custom model for client and server
CSJDeveloper opened this issue · comments
Describe the bug
For the examples/base_siamese
in personalizedFL sub-branch, I cannot define the custom model to be used as the input for the client and server. If the user directly instantiates the module, such as siamese_mnist_net.SiameseBase()
, line 57 of plato/clients/simple.py
is obviously not correct. If the user does not instantiates the module, such as siamese_mnist_net.SiameseBase
, line 13 of plato/algorithms/fedavg.py
utilizes the model without instantiation.
To Reproduce
Steps to reproduce the behavior:
- Go to
examples/base_siamese
in personalizedFL sub-branch. - Run
python examples/base_siamese/base_siamese.py -c examples/base_siamese/base_siamese_MNIST.yml
. - You can see the upper mentioned two different errors when using different ways to define the custom model.
Expected behavior
The code is expected to run smoothly.
Additional context
The error is clear as the Client and the Server use different ways to register the model.
In the client, the line 55 of plato/clients/simple.py
register the model as :
if self.custom_model is not None:
self.model = self.custom_model()
self.custom_model = None
However, in the server, the line 119 of plato/servers/fedavg.py
register the model as :
if self.model is None and self.custom_model is not None:
self.model = self.custom_model