google-research / federated

A collection of Google research projects related to Federated Learning and Federated Analytics.
Apache License 2.0
693 stars 196 forks source link

[large_cohort] AttributeError: 'LearningAlgorithmState' object has no attribute 'model' #61

Closed pratik98 closed 2 years ago

pratik98 commented 2 years ago

trying to run Large-Cohort Training for Federated Learning, following readme. getting this error.

large_cohort/trainer.py", line 272, in evaluation_fn
    return federated_evaluation_fn(state.model, evaluation_data)
AttributeError: 'LearningAlgorithmState' object has no attribute 'model'
PraChetit commented 2 years ago

The LearningAlgorithmState comes from [here].(https://github.com/tensorflow/federated/blob/a98b5ed6894c536549da06b4cc7ed116105dfe65/tensorflow_federated/python/learning/templates/composers.py#L46-L62)

The model weights you expect will be available as state.global_model_weights.

pratik98 commented 2 years ago

@PraChetit worked like a charm. Thanks.

amitport commented 2 years ago

@PraChetit Hey, note that this is still an issue in the example trainers (e.g., https://github.com/google-research/federated/blob/master/compressed_communication/trainer.py#L339). I can submit a PR renaming these if this is an error (at least for me it seems to be).