Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: What is the purpose of the tf.function decorator in TensorFlow 2.x?
Answer: The tf.function decorator is used to convert a Python function into a TensorFlow graph, allowing for better performance through graph execution and enabling graph optimizations.

Example:

@tf.function
def my_function(x):
    return x * x

Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook