tf.squeeze()


轉載自:https://www.cnblogs.com/mdumpling/p/8053376.html

  • 原型

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

      從tensor中刪除所有大小是1的維度

      給定張量輸入,此操作返回相同類型的張量,並刪除所有尺寸為1的尺寸。 如果不想刪除所有大小是1的維度,可以通過squeeze_dims指定。

 

  • 參數解釋
  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]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM