Table of Contents

tf.expand_dims()

Function Definition: tf.expand_dims(input, axis, name)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
inputstringA tensorTensor
axisintInteger specifying the dimension index at which to expand the shape of input. Given an input of D dimensions, axis must be in range [-(D+1), D] (inclusive).Integer0
namestringOptional string. The name of the output Tensor.String

Description

The function returns a tensor with a length 1 axis inserted at the index axis.

Given a tensor input, this operation inserts a dimension of length 1 at the dimension index axis of input‘s shape. The dimension index follows Python indexing rules: It’s zero-based, a negative index 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.

Import Libraries

####################imports####################
#do not change

import cv2
import numpy as np
import tensorflow as tf

#do not change
####################imports####################

Example

There are no examples documented for this article.