tff.learning.optimizers.check_weights_gradients_match

Checks that weights and non-none gradients match.

This check is meant to be used in the next method of implemented tff.learning.optimizers.Optimizer to check whether the provided weights and gradients match, and provide easy and more informative error message.

To match behavior of tf.keras.optimizers, this check will only be applied to gradient leaves that are not None.

weights A structure of tensors.
gradients A structure of tensors.

ValueError If weights and gradients do not have the same structure, or if the tensors in the structures do not have the same shapes and dtypes, at some leaf where gradients is not None.