tf_agents.utils.eager_utils.future_in_eager_mode
Stay organized with collections
Save and categorize content based on your preferences.
Decorator that allow a function/method to run in graph and in eager modes.
tf_agents.utils.eager_utils.future_in_eager_mode(
func_or_method
)
When applied in graph mode it calls the function and return its outputs.
When applied in eager mode it returns a lambda function that when called
returns the outputs.
@eager_utils.future_in_eager_mode
def loss_fn(x):
v = tf.get_variable('v', initializer=tf.ones_initializer(), shape=())
return v + x
with context.graph_mode():
loss_op = loss_fn(inputs)
loss_value = sess.run(loss_op)
with context.eager_mode():
loss = loss_fn(inputs)
# Now loss is a Future callable.
loss_value = loss()
Args |
func_or_method
|
A function or method to decorate.
|
Returns |
Either the output ops of the function/method or a Future (lambda function).
|
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-04-26 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-04-26 UTC."],[],[]]