Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

tf_agents.utils.common.function_in_tf1

View source on GitHub

Wrapper that returns common.function if using TF1.

tf_agents.utils.common.function_in_tf1(
    *args, **kwargs
)

This allows for code that assumes autodeps is available to be written once, in the same way, for both TF1 and TF2.

Usage:

train = function_in_tf1()(agent.train)
loss = train(experience)

Args:

  • *args: Arguments for common.function.
  • **kwargs: Keyword arguments for common.function.

Returns:

A callable that wraps a function.