1.6 TensorFlow: Verifying the installation
Once you have installed TensorFlow on your system, it is important to verify that the installation was successful. Here are some steps you can follow to verify the installation:
Step 1: Import TensorFlow
Open a Python shell or a Jupyter notebook and import TensorFlow by running the following command:
import tensorflow as tf
Step 2: Check the TensorFlow version
You can check the version of TensorFlow installed on your system by running the following command:
print(tf.__version__)
Step 3: Verify TensorFlow is using the correct backend
Check that TensorFlow is using the correct backend by running the following command:
print(tf.keras.backend.backend())
Step 4: Test TensorFlow with a simple program
Finally, you can test TensorFlow by running a simple program. Here is an example program that creates a constant and prints its value:
tf.compat.v1.enable_eager_execution()
x = tf.constant(5)
print(x)
If you see the value of the constant printed successfully, then your TensorFlow installation is working correctly.
By following these steps, you can verify that TensorFlow is correctly installed on your system and ready to use for machine learning projects.