All the tensors that are defined by f will be created inside a named scope.
The name of the scope will be the name of the original function (“foo”) — thanks to f.
One small problem is that while function names might start with “_”, tensorflow scope names can’t.
This is why we have to use re.
Why is it that important?The challenge of writing clean tensorflow code is negligible compared to the research challenge of actually making the model any good.
Thus, it’s easy to be tempted to just focus on the research aspects of your job.
However, in the long run, it’s important not to neglect the maintainability and readability of your code, including those of your graph.
The decorator approach make my job a little easier, and I hope you’ll benefit from it too.
Do you have other tips you’d like to share?.Drop a line in the comments!Originally published by me at engineering.