Show / Hide Table of Contents

    Method identity

    static member identity: ITensorDevice -> int64 -> Tensor<'T>

    Creates a new identity matrix.

    Declaration
    static member identity: dev:ITensorDevice -> size:int64 -> Tensor<'T>
    Parameters
    Type Name Description
    ITensorDevice dev

    The device to create the matrix on.

    int64 size

    The size of the square identity matrix.

    Returns
    Type Description
    Tensor<'T>

    The new tensor.

    Remarks

    A new square matrix of the specified size is created on the specified device.

    The tensor is filled with ones on the diagonal and zeros elsewhere.

    Examples
     let a = Tensor<float>.identity HostTensor.Dev 3L
     // a = [[1.0; 0.0; 0.0]
     //      [0.0; 1.0; 0.0]
     //      [0.0; 0.0; 1.0]]    
    Back to top Generated by DocFX