来源:https://tensorflow.google.cn/api_docs/python/tf/squeeze
tf.squeeze(
input,
axis=None,
name=None,
squeeze_dims=None
)
Removes dimensions of size 1 from the shape of a tensor. (deprecated arguments)
从Tensor的shape中去除size大小为1的维度们。。可以全部去除,也可以指定axis
举例:
# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
tf.shape(tf.squeeze(t)) # [2, 3]
# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
tf.shape(tf.squeeze(t, [2, 4])) # [1, 2, 3, 1]
Args:
input
: ATensor
. Theinput
to squeeze.axis
: An optional list ofints
. Defaults to[]
. If specified, only squeezes the dimensions listed. The dimension index starts at 0. It is an error to squeeze a dimension that is not 1. Must be in the range[-rank(input), rank(input))
.name
: A name for the operation (optional).squeeze_dims
: Deprecated keyword argument that is now axis.