Show / Hide Table of Contents

    Method reshape

    static member reshape: int64 list -> Tensor<'T> -> Tensor<'T>

    Changes the shape of a tensor.

    Declaration
    static member reshape: shp:int64 list -> a:Tensor<'T> -> Tensor<'T>
    Parameters
    Type Name Description
    int64 list shp

    The target shape.

    Tensor<'T> a

    The tensor to operate on.

    Returns
    Type Description
    Tensor<'T>

    A tensor of the specified shape.

    Remarks

    Changes the shape of the tensor to the specified shape. The total number of elements must not change. One dimension of the shp can be specified as val Remainder, in which case the size of that dimension is inferred automatically.

    If a reshape is possible without copying the data of the tensor, a view of the original tensor is returned and the storage is shared. In this case, modifications done to the returned tensor will affect the original tensor.

    If a reshape is not possible without copying the data of the tensor, a new tensor of the specified shape and a new storage is allocated and the data is copied into the new tensor.

    Examples
     let a = HostTensor.zeros [2L; 3L; 4L]
     let b = Tensor.reshape [6L; 4L] a // b.Shape = [6L; 4L]
     let c = Tensor.reshape [2L; Remainder; 1L] a // c.Shape = [2L; 12L; 1L]
    See Also
    static member tryReshapeView: int64 list -> Tensor<'T> -> Tensor<'T> option
    static member reshapeView: int64 list -> Tensor<'T> -> Tensor<'T>
    static member flatten: Tensor<'T> -> Tensor<'T>
    member Shape: unit -> int64 list
    Back to top Generated by DocFX