fedprox tensorflow federated (TypeError: cannot unpack non-iterable LearningProcessOutput object)

203 Views Asked by At
iterative_process = tff.learning.algorithms.build_unweighted_fed_prox( 
    model_fn,
    proximal_strength= 0.5,
    client_optimizer_fn=lambda: tf.keras.optimizers.SGD(learning_rate=0.01),
    server_optimizer_fn=lambda: tf.keras.optimizers.SGD(learning_rate=1.0))

state, metrics = iterative_process.next(state, federated_train_data)
print('round  1, metrics={}'.format(metrics))

On executing the round 1, it throws (TypeError: cannot unpack non-iterable LearningProcessOutput object).

It was working fine when we use Fedavg, but not with fedprox

1

There are 1 best solutions below

0
On

iterative_process.next returns LearningProcessOutput which is not iterable, as the error says.

You can replace it by

output = iterative_process.next(...)
state = output.state
metrics = output.metrics

or just use the output directly.