tff.learning.optimizers.check_weights_gradients_match
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 .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[]]