Error using update_struct function in TensorFlow Federated

Viewed 118

I'm attempting to run the Minimal Stand-Alone Implementation of Federated Averaging from the TensorFlow Federated GitHub repository but receiving the following error in the server_update function:

AttributeError: module 'tensorflow_federated.python.common_libs.structure' has no attribute 'update_struct'

I have some old TensorFlow Federated code that uses the update_state function from the tff.utils package in place of update_struct() but according to a commit on GitHub this package is empty now. I'm using TensorFlow Federated version 0.18.0 and I also had the same problem trying on Google CoLab.

My question is how can I fix this error?

Thanks, any help appreciated.

1 Answers

I am assuming you hit the error you describe here.

It seems that the symbol is not in the 0.18 release. You can either depend on the nightly version (pip install tensorflow-federated-nightly), or modify the line to construct the new object directly, instead of using the update_struct helper. That is, the linked command could change to:

return ServerState(model_weights,
                   server_optimizer.variables(),
                   server_state.round_num + 1))
Related