Hands-On Deep Learning Architectures with Python
上QQ阅读APP看书,第一时间看更新

Testing your installation

To test whether you have successfully installed or not, you can run the following snippet in Python. If you have installed the GPU version, import TensorFlow in Python and run the following:

>>>import tensorflow as tf
>>>sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

This will return the details about the GPU card and other details that TensorFlow is compiled to use, if you have successfully installed the GPU version.

To check the installation properly (irrespective of CPU or GPU version), we will perform the following simple tensor multiplication operation:

>>>t1 = tf.constant([8.0, 4.0, 3.0, 10.0, 9.0, 2.0], shape = [2,3],name='tensor1')
>>>t2 = tf.constant([12.0, 6.0, 4.0, 5.0, 9.0, 1.0], shape = [3,2],name='tensor2')
>>>out = tf.matmul(t1, t2)
>>>sess = tf.Session()
>>>print(session.run(out))

This code must print the element-wise multiplied output of the two tensors.