tf.expand_dims code example

Example: tf.expand_dims

tf.expand_dims(
    input, axis, name=None
)

Given a tensor input, this operation inserts a dimension of size 1 
at the dimension index axis of input's shape. The dimension index 
axis starts at zero; if you specify a negative number for axis it is 
counted backward from the end.
This operation is useful if you want to add a batch dimension to a 
single element. For example, if you have a single image of shape 
[height, width, channels], you can make it a batch of one image with 
expand_dims(image, 0), which will make the shape 
[1, height, width, channels].

Tags:

Misc Example