November 2018
Intermediate to advanced
322 pages
7h 54m
English
While constants store the value at the time of defining the tensor, placeholders allow you to create empty tensors so that the values can be provided at runtime. The TensorFlow library provides the tf.placeholder() function with the following signature to create placeholders:
tf.placeholder( dtype, shape=None, name=None )
As an example, let's create two placeholders and print them:
p1 = tf.placeholder(tf.float32)p2 = tf.placeholder(tf.float32)print('p1 : ', p1)print('p2 : ', p2)
The following output shows that each placeholder has been created as a tensor:
p1 : Tensor("Placeholder:0", dtype=float32)p2 : Tensor("Placeholder_1:0", dtype=float32)
Let's define an operation using these placeholders:
mult_op = p1 * p2
In TensorFlow, shorthand ...
Read now
Unlock full access