Exemplo n.º 1
0
def reshape(tensor, shape, copy=True, name=None):
    """Change the dimensions of input.

    Examples:

    ```python
    # Provide a determined value for each dimension if possible
    x = tf.ones(shape=(1, 2, 3, 4))
    print(tf.reshape(x, shape=[6, 4]).shape)  # [6, 4]

    # Set the existing dimensions to ``0`` if it unchanged
    print(tf.reshape(x, shape=[0, 0, 12]).shape)  # [1, 2, 12]
    print(tf.reshape(x, shape=[0, 0, 0, 0]).shape)  # [1, 2, 3, 4]
    print(tf.reshape(x, shape=[0, 0, 0, 0, 0]).shape)  # Wrong

    # You can also set ``-1`` once to infer the value
    print(tf.reshape(x, shape=[-1, 4]).shape)  # [6, 4]
    print(tf.reshape(x, shape=[-1, -1]).shape)  # Wrong
    ```

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

    name : str, optional
        The operation name.

    """
    return array_ops.reshape(tensor, shape=shape, copy=copy, name=name)
Exemplo n.º 2
0
def reshape(self, shape):
    """Return a tensor containing the same data with new shape.

    Parameters
    ----------
    shape : Sequence[int]
        The new shape.

    Returns
    -------
    dragon.EagerTensor
        The output tensor.

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

    """
    with context.eager_mode():
        return array_ops.reshape(self, shape=shape)
Exemplo n.º 3
0
def reshape(self, shape, copy=True):
    """Return a tensor containing the same data with new shape.

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

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

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

    """
    return array_ops.reshape(self, shape=shape, copy=copy)
Exemplo n.º 4
0
 def forward(self, inputs, **kwargs):
     return array_ops.reshape(inputs, shape=self.shape)
Exemplo n.º 5
0
 def call(self, inputs):
     return array_ops.reshape(inputs, shape=[0] + self.target_shape)
Exemplo n.º 6
0
 def __call__(self, bottom):
     return array_ops.reshape(bottom, **self.arguments)
Exemplo n.º 7
0
 def __call__(self, bottom):
     return array_ops.reshape(bottom, **self.call_args)