I'm newbie in Tensorflow and I'm developing a notebook in Google Colaboratory.
On my first notebooks I got a message saying to update to Tensorflow v.2.
Now, in another notebook, I get the following message:
The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.
If I do that, am I using Tensorflow v2?
I'm confuse because of the v1
in tf.compat.v1.get_default_graph
.
All the error messages are:
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:66: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:541: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:4432: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:4267: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.
I think I can't change that code on keras.
You still get some of these errors even if you use TF 1.1X, where X = 3/4/5.
Some of the libraries are already being deprecated, although available in TF 1.13/1.14/1.15. Note that TF 1.15 is the latest release for the version 1.X.
To ensure that you are using TensorFlow 2.0, use:
import tensorflow as tf
print(tf.__version__)
There are a couple of notable differences between the TensorFlow 1.X API and TensorFlow 2.X API; since you are a beginner, I would strongly recommend that you stick to the latest versions and take into consideration every deprecation warning, so as to use the newest updates.
The function tf.compat.v1.get_default_graph()
is part of the TensorFlow 2.0 API: https://www.tensorflow.org/api_docs/python/tf/Graph?version=stable