To run the constant scalar addition in a TensorFlow session, we could just evaluate it with a session run operation. n(tf.global_variables_initializer())Īll right, so we got here and all of our variables have been initialized. Next, let’s initialize all the global variables in the graph. Now that we’ve created our TensorFlow graph, it’s time to run the computational graph. We see that it’s a TensorFlow tensor, we see that it’s an “Add”, we see that the shape is empty signifying that it’s still a scalar, and the data type is int32. Let’s print the tf_constant_sum Python variable to see what we have. So we’re going to do tf.add, we pass in our first scalar, tf_constant_one, and we’re going to pass in our second scalar, tf_constant_two, and the result of this will be assigned to the Python variable tf_constant_sum. Tf_constant_sum = tf.add(tf_constant_one, tf_constant_two) Let’s now build a computational graph node that adds the two constant scalars together. Since we are in the building the graph stage, both of these TensorFlow constant scalars haven’t been evaluated in a TensorFlow session yet, so what you have are uninitialized variables. Remember that TensorFlow builds the graph first and then later evaluates the graph. We see that it’s a TensorFlow tensor, the name is “twenty”, the shape is empty, and the data type is int32. Let’s print the tf_constant_two Python variable to see what we have. We assign it to the Python variable tf_constant_two. Tf_constant_two = tf.constant(20, name="twenty")Īgain, using tf.constant, we give it the value of 20 and the name of the string written out “twenty”. Next, let’s define our second constant scalar. We see that it’s a TensorFlow tensor with the name of “ten”, the shape is empty because it’s a scalar, and the data type is int32. Let’s print the tf_constant_one Python variable to see what we have. We give it the value of 10, and we give it the name of the string of “ten”, and we assign it to the Python variable tf_constant_one. Tf_constant_one = tf.constant(10, name="ten") The example we’re going to create in this video is to add two named TensorFlow scalars together using the TensorFlow add operation, then we’ll look at the graph that’s generated. Then we print out the TensorFlow version that we are using. In this video, we’re going to use tf.summary.FileWriter to create a TensorFlow Summary FileWriter for TensorBoard.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |