You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In client/numpy_client.py the EXCEPTION_MESSAGE_WRONG_RETURN_TYPE_FIT constant is set to:
EXCEPTION_MESSAGE_WRONG_RETURN_TYPE_FIT = """
NumPyClient.fit did not return a tuple with 3 elements.
The returned values should have the following type signature:
Tuple[NDArrays, int, Dict[str, Scalar]]
Example
-------
model.get_weights(), 10, {"accuracy": 0.95}
"""
However, function _fit(...), that checks returned value type wants a Tuple[List, int, Dict[str,Scalar]]
def _fit(self: Client, ins: FitIns) -> FitRes:
"""Refine the provided parameters using the locally held dataset."""
# Deconstruct FitIns
parameters: NDArrays = parameters_to_ndarrays(ins.parameters)
# Train
results = self.numpy_client.fit(parameters, ins.config) # type: ignore
if not (
len(results) == 3
and isinstance(results[0], list)
and isinstance(results[1], int)
and isinstance(results[2], dict)
):
print(results)
print(len(results))
raise TypeError(EXCEPTION_MESSAGE_WRONG_RETURN_TYPE_FIT)
Therefore, the error message printed is misleading for the users.
Steps/Code to Reproduce
To reproduce you simply need to implements a fit(...) function inside the numpy_client that returns a tuple with signature Tuple[NDArrays, int, Dict[str, Scalar]] as indicated in the error string.
Describe the bug
In client/numpy_client.py the EXCEPTION_MESSAGE_WRONG_RETURN_TYPE_FIT constant is set to:
However, function _fit(...), that checks returned value type wants a Tuple[List, int, Dict[str,Scalar]]
Therefore, the error message printed is misleading for the users.
Steps/Code to Reproduce
To reproduce you simply need to implements a fit(...) function inside the numpy_client that returns a tuple with signature Tuple[NDArrays, int, Dict[str, Scalar]] as indicated in the error string.
For example:
Expected Results
Returning Tuple[NDArrays, int, Dict[str, Scalar]] should work as written in the error message, or the string should be fixed.
Actual Results
Returning a Tuple[NDArrays, int, Dict[str, Scalar]] in the fit function results in a raised exception and then an error.
The text was updated successfully, but these errors were encountered: