Defining placeholder variables
In this recipe, let's define the placeholder variables that serve as input to the modules in a TensorFlow computational graph. These are typically multidimensional arrays or matrices in the form of tensors.
Getting ready
The data type of placeholder variables is set to float32 (tf$float32
) and the shape is set to a two-dimensional tensor.
How to do it...
- Create an input placeholder variable:
x = tf$placeholder(tf$float32, shape=shape(NULL, img_size_flat), name='x')
The NULL value in the placeholder allows us to pass non-deterministic arrays size.
- Reshape the input placeholder
x
into a four-dimensional tensor:
x_image = tf$reshape(x, shape(-1L, img_size, img_size, num_channels))
- Create an output placeholder variable:
y_true = tf$placeholder(tf$float32, shape=shape(NULL, num_classes), name='y_true')
- Get the (
true
) classes of the output using argmax:
y_true_cls = tf$argmax(y_true, dimension=1L)
How it works...
In step 1, we define an input placeholder variable. The dimensions...