Shortest possible version of question:
When checking TensorFlow version in Python, can somebody explain/clarify the difference between tf.__version__
and tf.VERSION
??
Slightly longer version of question:
This seems to work:
if tf.__version__ < "1.8.0":
print("ERROR: currently running TensorFlow version " + tf.__version__ + ", at least version 1.8.0 is required")
return
# end if
This also seems to work:
if tf.VERSION < "1.8.0":
print("ERROR: currently running TensorFlow version " + tf.VERSION + ", at least version 1.8.0 is required")
return
# end if
One difference I have noticed is that the editor PyCharm shows a warning for the tf.__version__
way but does not for the tf.VERSION way:
A work around for this in PyCharm is to add the # noinspection PyUnresolvedReferences
comment above each tf.__version__
useage, which resolved the warning:
However the tf.VERSION
way does not show a warning in PyCharm without the # noinspection PyUnresolvedReferences
comment:
I asked about the PyCharm tf.__version__
warning in this post:
TensorFlow Python warning in PyCharm - Cannot find reference __version__ in __init__.py
and the only responder stated that tf.__version__
is generated dynamically. In the context of Python specifically I don't really understand what this means.
So at this point I have the following questions:
1) Why do both of these exist?
2) Is one generally recommended over the other?
3) Why does PyCharm show a warning for one but not the other?
4) What does it mean that tf.__version__
is generated dynamically? How is tf.VERSION
generated if a different way?
5) To avoid having to add the # noinspection PyUnresolvedReferences
comment I'd prefer to use tf.VERSION
, is there any reason not to do this?
6) Most of the examples within the TensorFlow repository https://github.com/tensorflow/tensorflow and the related repositories (ex. models https://github.com/tensorflow/models) use the tf.__version__
way but some use the tf.VERSION
way, is there a reason for this?