Tensorflow with Python code I want to integrate simple python code with in the tensorflow graph.
I'm not sure if it's feasible. If feasible, please suggest how to integrate it.
Use case is, I want feed the output of intermediate tensor as an input to my python code and then python code output to another tensor.
Does @tf.function can be use here?
Thanks.
Yes, theoretically that's what tf.function does. This uses a tensorflow module called AutoGraph to basically convert your python/numpy operations to tensorflow ops.
However not all python operations can be converted. Things like printing, appending to lists and mutating global variables won't work in graph mode!
I suggest you take a look at the official guide to see how it is used and if it is applicable in your situation.