I was following this article, which uses tf.app in its second point. When I ran the code, I got :
AttributeError: module 'tensorflow' has no attribute 'app'
The reason for this error is that Tensorflow 2.x no more supports tf.app.module.
But hold on, there are alternatives! The alternatives are gflags ( for FLAGS) and google.apputils.app (for tf.app).
To use gflags, you first need to pip install gflags:
pip install python-gflags
Now, you can use them in a similar way to tf.app.FLAG. There are slight name changes in parameter names:
flag_name becomes name, default_value becomes default & docstring becomes help.
Old code with tf.app.FLAGS
New code with gflags :
import tensorflow.compat.v1 as tf
No comments:
Post a Comment