View source on GitHub |
Checks that weights and non-none gradients match.
tff.learning.optimizers.check_weights_gradients_match(
weights: _Structure[tf.Tensor],
gradients: _Structure[Union[tf.Tensor, None]]
) -> None
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
.
Args | |
---|---|
weights
|
A structure of tensors. |
gradients
|
A structure of tensors. |
Raises | |
---|---|
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 .
|