tfp.experimental.nn.util.make_fit_op
Stay organized with collections
Save and categorize content based on your preferences.
One training step.
tfp.experimental.nn.util.make_fit_op(
loss_fn,
optimizer,
trainable_variables,
grad_summary_fn=None,
tf_function=True,
xla_compile=True
)
Args |
loss_fn
|
Python callable which returns the pair loss (tf.Tensor ) and
any other second result such that
tf.nest.map_structure(tf.convert_to_tensor, other) will succeed.
|
optimizer
|
tf.optimizers.Optimizer -like instance which has members
gradient and apply_gradients .
|
trainable_variables
|
tf.nest.flatten -able structure of tf.Variable
instances.
|
grad_summary_fn
|
Python callable which takes a trainable_variables -like
structure of tf.Tensor s representing the gradient of the result of
loss_fn with respect to trainable_variables . For example,
lambda grads: tf.nest.map_structure(
lambda x: 0. if x is None else tf.norm(x), grads) .
Default value: None (i.e., no summarization is made).
|
tf_function
|
bool representing whether the resulting function should be
tf.function decoreated.
Default value: True .
|
xla_compile
|
bool representing whether XLA compilation should be
performed. (This argument is ignored if the function is executed eagerly.)
Default value: True .
|
Returns |
fit_op
|
A Python callable taking args which are forwarded to loss_fn and
such that when called trainable_variables are updated per the logic of
optimizer.apply_gradients .
|
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-01-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-01-12 UTC."],[],[]]