zoukankan      html  css  js  c++  java
  • tf.squeeze

    https://www.w3cschool.cn/tensorflow_python/tensorflow_python-1yed2mih.html

    @tf_export(v1=["squeeze"])
    @dispatch.add_dispatch_support
    @deprecation.deprecated_args(None, "Use the `axis` argument instead",
                                 "squeeze_dims")
    def squeeze(input, axis=None, name=None, squeeze_dims=None):
      # pylint: disable=redefined-builtin
      """Removes dimensions of size 1 from the shape of a tensor.
    从tensor的形状中移除size = 1的维度。
    
      Given a tensor `input`, this operation returns a tensor of the same type with
      all dimensions of size 1 removed. If you don't want to remove all size 1
      dimensions, you can remove specific size 1 dimensions by specifying
      `axis`.
    给定一个input tensor,这个操作会返回一个同样类型的tensor并且移除了所有size = 1的维度。如果你不想移除所有size=1的维度,可以通过axis指定想要移除的维度。
    
      For example:
    
      ```python
      # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
      tf.shape(tf.squeeze(t))  # [2, 3]
    

    Or, to remove specific size 1 dimensions:

    # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
    tf.shape(tf.squeeze(t, [2, 4]))  # [1, 2, 3, 1]
    

    Note: if input is a tf.RaggedTensor, then this operation takes O(N)
    time, where N is the number of elements in the squeezed dimensions.
    Note:如果input是一个RaggedTensor,那么这个操作会花费O(N)的时间。

    Args:
    input: A Tensor. The input to squeeze.
    intput:一个Tensor。

    axis: 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. Must be in the range
      `[-rank(input), rank(input))`.
      Must be specified if `input` is a `RaggedTensor`.
    

    axis:可选,ints,默认[]。如果指定了,就仅压缩指定维度。维度从0开始。如果尝试压缩维度不为1的的维度会出错。如果是RaggedTensor,一定要指定。

    name: A name for the operation (optional).
    squeeze_dims: Deprecated keyword argument that is now axis.
    

    squeeze_dims:已废弃。现在建议使用axis。

    Returns:
    A Tensor. Has the same type as input.
    Contains the same data as input, but has one or more dimensions of
    size 1 removed.

    Raises:
    ValueError: When both squeeze_dims and axis are specified.
    同时指定squeeze_dims和axis会出错。
    """

  • 相关阅读:
    怎么获取数组中的对象的某一项之和
    原型链
    js的事件循环(Eventloop) 机制/js的宏任务微任务执行顺序
    怎么替换数组中对象的属性
    求对象所有值的和
    sequelize中duplicating:false的使用
    WebSocket
    轮播

    ssl tsl
  • 原文地址:https://www.cnblogs.com/CheeseZH/p/13410814.html
Copyright © 2011-2022 走看看