matrix
The matrix power calculates the powers of input matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mx
|
Tensor
|
The matrix to be powered. |
required |
n
|
int
|
The power of the matrix. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The matrix power. |
Source code in tinybig/koala/linear_algebra/matrix.py
The accumulative matrix power is defined as the summation of matrix powers from 1 to n.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mx
|
Tensor
|
The input matrix. |
required |
n
|
int
|
The highest power order. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The summation of matrix powers from 1 to n. |
Source code in tinybig/koala/linear_algebra/matrix.py
Degree-based normalization of the matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mx
|
Tensor
|
The input matrix (can be dense or sparse). |
required |
mode
|
str
|
The normalization mode. Can be 'row', 'column', or 'row-column'. |
'row'
|
Returns:
Type | Description |
---|---|
Tensor
|
The normalized matrix. |
Source code in tinybig/koala/linear_algebra/matrix.py
Applies normalization using a specified operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mx
|
Tensor
|
The input matrix (can be dense or sparse). |
required |
rescale_factor
|
float
|
Factor by which to rescale the input matrix. |
1.0
|
operator
|
callable
|
Function to apply for normalization (e.g., softmax). |
softmax
|
mode
|
The normalization mode. Can be 'row', 'column', or 'row-column'. |
'row'
|
Returns:
Type | Description |
---|---|
Tensor
|
The normalized matrix. |
Source code in tinybig/koala/linear_algebra/matrix.py
Normalize the input tensor X based on the specified mode.
Parameters: X (torch.Tensor): Input data tensor of shape (t, n) where t denotes timestamps and n denotes stock instances. mode (str): Mode of normalization. Possible values are "row", "column", or "row_column".
Returns: torch.Tensor: Normalized tensor X.
Source code in tinybig/koala/linear_algebra/matrix.py
Convert a scipy sparse matrix to a torch sparse tensor.