更新说明:使用axis参数。给定一个张量输入,这个操作在输入形状的维数索引轴上插入一个维数为1的维度。尺寸指标轴从零开始; 如果为轴指定一个负数,则从末尾向后计数。...别的例子:# 't' is a tensor of shape [2]tf.shape(tf.expand_dims(t, 0)) # [1, 2]tf.shape(tf.expand_dims(t,...1)) # [2, 1]tf.shape(tf.expand_dims(t, -1)) # [2, 1]# 't2' is a tensor of shape [2, 3, 5]tf.shape(...tf.expand_dims(t2, 0)) # [1, 2, 3, 5]tf.shape(tf.expand_dims(t2, 2)) # [2, 3, 1, 5]tf.shape(tf.expand_dims...返回值:一个与输入数据相同的张量,但它的形状增加了尺寸为1的额外维数。