Exemplo n.º 1
0
def transpose(a, perm=None, name=None):
    r"""Permute the dimensions of input.

    Examples:

    ```python
    # Provide the permutation for all axes
    x = tf.ones(shape=(2, 3, 4))
    print(tf.transpose(x, (0, 2, 1)).shape)  # (2, 4, 3)

    # Or dimensions will be simply inverse
    print(tf.transpose(x).shape)  # (4, 3, 2)
    ```

    Parameters
    ----------
    a : dragon.Tensor
        The input tensor.
    perm : Sequence[Union[int, dragon.Tensor]]
        The output permutation.
    name : str, optional
        The operation name.

    Returns
    -------
    dragon.Tensor
        The output tensor.

    """
    return array_ops.transpose(a, perm=perm, name=name)
Exemplo n.º 2
0
def transpose(self, perm=None, copy=True):
    """Return a tensor with permuted axes.

    Parameters
    ----------
    perm : Union[Sequence[int], dragon.Tensor]], optional
        The output permutation.
    copy : bool, optional, default=True
        Return a new tensor or transpose in-place.

    Returns
    -------
    dragon.Tensor
        The output tensor.

    See Also
    --------
    `dragon.transpose(...)`_

    """
    return array_ops.transpose(self, perm=perm, copy=copy)
Exemplo n.º 3
0
 def forward(self, inputs, **kwargs):
     return array_ops.transpose(inputs, perm=self.perm)
Exemplo n.º 4
0
 def call(self, inputs):
     return array_ops.transpose(inputs, perm=[0] + self.dims)
Exemplo n.º 5
0
 def __call__(self, bottom):
     return array_ops.transpose(bottom, **self.arguments)
Exemplo n.º 6
0
 def call(self, inputs):
     if self.data_format == 'channels_first':
         perm = [0] + [i for i in range(2, len(inputs.shape))] + [1]
         inputs = array_ops.transpose(inputs, perm=perm)
     return array_ops.flatten(inputs, keep_axes=2)
Exemplo n.º 7
0
 def __call__(self, bottom):
     return array_ops.transpose(bottom, **self.call_args)