|TensorFlow 1 version||View source on GitHub|
Returns a tensor with a length 1 axis inserted at index
tf.expand_dims( input, axis, name=None )
Used in the notebooks
|Used in the guide||Used in the tutorials|
Given a tensor
input, this operation inserts a dimension of length 1 at the
input's shape. The dimension index follows Python
indexing rules: It's zero-based, a negative index it is counted backward
from the end.
This operation is useful to:
- Add an outer "batch" dimension to a single element.
- Align axes for broadcasting.
- To add an inner vector length axis to a tensor of scalars.
If you have a single image of shape
[height, width, channels]:
image = tf.zeros([10,10,3])
You can add an outer
batch axis by passing