tf.squeeze()

转载自:http://www.javashuo.com/article/p-mvwbjeqv-bq.htmlhtml

  • 原型

      tf.squeeze(input, squeeze_dims=None, name=None)spa

      从tensor中删除全部大小是1的维度code

      给定张量输入,此操做返回相同类型的张量,并删除全部尺寸为1的尺寸。 若是不想删除全部大小是1的维度,能够经过squeeze_dims指定。htm

 

  • 参数解释
  1. input: A Tensor. The input to squeeze. 
  2. squeeze_dims: An optional list of ints. 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. 
  3. name: A name for the operation (optional).

 

  • 示例
# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t)) ==> [2, 3]
Or, to remove specific size 1 dimensions:

# 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1]
相关文章
相关标签/搜索