What is the difference in purpose between tf.py_function and tf.function?
问题 The difference between the two is muddled in my head, notwithstanding the nuances of what is eager and what isn't. From what I gather, the @tf.function decorator has two benefits in that it converts functions into TensorFlow graphs for performance, and allows for a more Pythonic style of coding by interpreting many (but not all) common-place Python operations into tensor operations, e.g. if into tf.cond , etc. From the definition of tf.py_function , it seems that it does just #2 above. Hence,