LearningProcess Compatibility Error
SaiSharanyaY opened this issue · comments
Code Snip
svhn_iterative_process = tff.learning.algorithms.build_weighted_fed_avg(
modelsvhn_fn,
client_optimizer_fn=lambda: tf.keras.optimizers.SGD(learning_rate=0.02),
server_optimizer_fn=lambda: tf.keras.optimizers.SGD(learning_rate=1))
svhnstate = svhn_iterative_process.initialize()
svhnstate_with_model = svhn_iterative_process.get_model_weights(svhnstate)
svhn_evaluation = tff.learning.algorithms.build_fed_eval(modelsvhn_fn)
federated_train_data_svhn =make_federated_data_svhn(svhn_data, clientlist)
overallLosssvhn = svhn_evaluation(svhnstate_with_model, federated_train_data_svhn)
Query
This is the iterative procedure I am following, for overall evaluation I am facing an error of LearningProcess is not compatible for the overallLosssvhn, Is there any way to solve it or convert it into a model ? [.model is not compatible]
As found in one issue, svhn_iterative_process.initialize()
doesn't have a .model attribute. So instead model weight was obtained using svhn_iterative_process.get_model_weights(state)
but while using it in overallLosssvhn it's throwing an error saying LearningProcess can't be passed whereas we are providing model weights using .get_model_weights.
Can you post a full stack trace? Additionally, as @JDRanpariya mentions, you can't pass the state of the learning process into your federated evaluation, it just expects the model weights. The setup they describe, ie. something like
weights = svhn_iterative_process.get_model_weights(state)
svhn_evaluation(weights, federated_train_data_svhn)
makes sense, but if this is causing you errors please post the full logs.