예제 #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)
예제 #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)
예제 #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)
예제 #4
0
 def forward(self, inputs, **kwargs):
     return array_ops.reshape(inputs, shape=self.shape)
예제 #5
0
 def call(self, inputs):
     return array_ops.reshape(inputs, shape=[0] + self.target_shape)
예제 #6
0
파일: common.py 프로젝트: ORG-MARS/dragon
 def __call__(self, bottom):
     return array_ops.reshape(bottom, **self.arguments)
예제 #7
0
 def __call__(self, bottom):
     return array_ops.reshape(bottom, **self.call_args)