Placeholders in TensorFlow
TensorFlow has special mechanisms for feeding data. One of these mechanisms is the use of placeholders, which are predefined tensors with specific types and shapes.
These tensors are added to the computation graph using the tf.placeholder
function, and they do not contain any data. However, upon the execution of certain nodes in the graph, these placeholders need to be fed with data arrays.
In the following sections, we'll see how to define placeholders in a graph and how to feed them with data values upon execution.
Defining placeholders
As you now know, placeholders are defined using the tf.placeholder
function. When we define placeholders, we need to decide what their shape and type should be, according to the shape and type of the data that will be fed through them upon execution.
Let's start with a simple example. In the following code, we will define the same graph that was shown in the previous section for evaluating . This time, however, we use placeholders...