cagpjax.policies.block_sparse
Block-sparse policy.
BlockSparsePolicy
Bases: AbstractBatchLinearSolverPolicy
Block-sparse linear solver policy.
This policy uses a fixed block-diagonal sparse structure to define independent learnable actions. The matrix has the following structure:
These are stacked and stored as a single trainable parameter nz_values
.
Source code in src/cagpjax/policies/block_sparse.py
n_actions
property
Number of actions to be used.
__init__(n_actions, n=None, nz_values=None, key=None, **kwargs)
Initialize the block sparse policy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_actions
|
int
|
Number of actions to use. |
required |
n
|
int | None
|
Number of rows and columns of the full operator. Must be provided if |
None
|
nz_values
|
Float[Array, N] | Variable[Float[Array, N]] | None
|
Non-zero values of the block-diagonal sparse matrix (shape |
None
|
key
|
PRNGKeyArray | None
|
Random key for sampling actions if |
None
|
**kwargs
|
Additional keyword arguments for |
{}
|
Source code in src/cagpjax/policies/block_sparse.py
to_actions(A)
Convert to block diagonal sparse action operators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
LinearOperator
|
Linear operator (unused). |
required |
Returns:
Type | Description |
---|---|
LinearOperator
|
Transposed[BlockDiagonalSparse]: Sparse action structure representing the blocks. |