Show / Hide Table of Contents

    Method gather

    static member gather: Tensor<int64> option list -> Tensor<'T> -> Tensor<'T>

    Selects elements from a tensor according to specified indices.

    Declaration
    static member gather: indices:Tensor<int64> option list -> src:Tensor<'T> -> Tensor<'T>
    Parameters
    Type Name Description
    Tensor<int64> option list indices

    A list of tensors, one per dimension of src, containing the indicies to pick from src for each output element.

    Tensor<'T> src

    The tensor containing the source values.

    Returns
    Type Description
    Tensor<'T>

    Result with the shape of the (broadcasted) tensors specified in indices.

    Remarks

    The output element with indices [i_0; i_1; i_2; ...] is given by the source element with indices [j_0; j_1; j_2; ...], where each index j_k is given by j_k = indices.[k].[i_0; i_1; i_2; ...]. If indices.[k] is None, then j_k = i_k is assumed instead. Index dimensions beyond the number of target dimensions must not be None.

    The tensors indices and src must have the same storage. All index tensors are broadcasted to the same size.

    Examples
     let src = HostTensor.ofList2D [[0.0; 0.1; 0.2; 0.3]
                                    [1.0; 1.1; 1.2; 1.3]
                                    [2.0; 2.1; 2.2; 2.3]]
     let i0 = HostTensor.ofList [1L; 2L; 0L; 0L]
     let i1 = HostTensor.ofList [3L; 1L; 0L; 3L]
     let g = Tensor.gather [Some i0; Some i1] src // g = [1.3000    2.1000    0.0000    0.3000]
    
     // Using None instead of an index tensor.    
     let j1 = HostTensor.ofList [3L; 1L; 0L]
     let g2 = Tensor.gather [None; Some j1] src // g2 = [0.3000    1.1000    2.0000]
    See Also
    member FillGather: Tensor<int64> option list -> Tensor<'T> -> unit
    static member scatter: Tensor<int64> option list -> int64 list -> Tensor<'T> -> Tensor<'T>
    Back to top Generated by DocFX