spd_learn.init.spd_identity_#

spd_learn.init.spd_identity_(tensor: Tensor) → Tensor[source]#

Initialize tensor as identity matrix (in-place).

Sets the tensor to the identity matrix. The tensor must be square (last two dimensions equal).

Parameters:

tensor (torch.Tensor) – Tensor to initialize, with shape (…, n, n).

Returns:

The initialized tensor (same object as input, modified in-place).

Return type:

torch.Tensor

Examples

>>> import torch
>>> from spd_learn import init as spd_init
>>> X = torch.empty(3, 4, 4)
>>> spd_init.spd_identity_(X)
>>> torch.allclose(X[0], torch.eye(4))
True

See also

stiefel_()

Initialize on Stiefel manifold.