params
#
Classes:
Name | Description |
---|---|
BNNParameter |
|
GaussianParameter |
Parameter of a BNNModule with Gaussian distribution. |
FactorizedCovariance |
Covariance of a Gaussian parameter with a factorized structure. |
DiagonalCovariance |
Covariance of a Gaussian parameter with diagonal structure. |
KroneckerCovariance |
Covariance of a Gaussian parameter with Kronecker structure. |
LowRankCovariance |
Covariance of a Gaussian parameter with low-rank structure. |
BNNParameter
#
GaussianParameter
#
GaussianParameter(
mean: (
Float[Tensor, "parameter"]
| dict[str, Float[Tensor, "parameter"]]
),
cov: FactorizedCovariance,
)
Bases: BNNParameter
Parameter of a BNNModule with Gaussian distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mean
|
Float[Tensor, 'parameter'] | dict[str, Float[Tensor, 'parameter']]
|
Mean of the Gaussian distribution. |
required |
cov
|
FactorizedCovariance
|
Covariance of the Gaussian distribution. |
required |
Methods:
Name | Description |
---|---|
sample |
|
Attributes:
Name | Type | Description |
---|---|---|
cov |
|
FactorizedCovariance
#
FactorizedCovariance(rank: int | None = None)
Bases: Module
Covariance of a Gaussian parameter with a factorized structure.
Assumes the covariance is factorized as a product of a square matrix and its transpose.
..math:: \mathbf{\Sigma} = \mathbf{S} \mathbf{S}^\top
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rank
|
int | None
|
Rank of the covariance matrix. If |
None
|
Methods:
Name | Description |
---|---|
factor_matmul |
Multiply left factor of the covariance matrix with the input. |
initialize_parameters |
Initialize the covariance parameters. |
reset_parameters |
Reset the parameters of the covariance matrix. |
to_dense |
Convert the covariance matrix to a dense representation. |
Attributes:
Name | Type | Description |
---|---|---|
lr_scaling |
dict[str, float]
|
Compute the learning rate scaling for the covariance parameters. |
rank |
|
lr_scaling
#
Compute the learning rate scaling for the covariance parameters.
factor_matmul
#
initialize_parameters
#
reset_parameters
#
Reset the parameters of the covariance matrix.
Initalizes the parameters of the covariance matrix with a scale that is given by the mean parameter scales and a covariance-specific scaling that depends on the structure of the covariance matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mean_parameter_scales
|
dict[str, float] | float
|
Scales of the mean parameters. If a dictionary keys are the names of the mean parameters. If a float, all covariance parameters are initialized with the same scale. |
1.0
|
DiagonalCovariance
#
Bases: FactorizedCovariance
Covariance of a Gaussian parameter with diagonal structure.
Methods:
Name | Description |
---|---|
factor_matmul |
|
initialize_parameters |
|
reset_parameters |
|
to_dense |
Convert the covariance matrix to a dense representation. |
Attributes:
Name | Type | Description |
---|---|---|
lr_scaling |
dict[str, float]
|
|
rank |
|
KroneckerCovariance
#
Bases: FactorizedCovariance
Covariance of a Gaussian parameter with Kronecker structure.
Assumes the covariance is given by a Kronecker product of two matrices of size
equal to the number of inputs and outputs to the layer. Each Kronecker factor is
assumed to be of rank :math:R \leq D
where :math:D
is either the input or
output dimension of the layer.
More precisely, the covariance is given by
where :math:\mathbf{S}_{\text{in}}
and :math:\mathbf{S}_{\text{out}}
are the
low-rank factors of the Kronecker factors :math:\mathbf{C}_{\text{in}}
and
:math:\mathbf{C}_{\text{out}}
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_rank
|
int | None
|
Rank of the input Kronecker factor. If None, assumes full rank. |
None
|
output_rank
|
int | None
|
Rank of the output Kronecker factor. If None, assumes full rank. |
None
|
Methods:
Name | Description |
---|---|
factor_matmul |
|
initialize_parameters |
|
reset_parameters |
|
to_dense |
|
Attributes:
Name | Type | Description |
---|---|---|
input_rank |
|
|
lr_scaling |
dict[str, float]
|
Compute the learning rate scaling for the covariance parameters. |
output_rank |
|
|
rank |
|
|
sample_scale |
float
|
|
LowRankCovariance
#
LowRankCovariance(rank: int)
Bases: FactorizedCovariance
Covariance of a Gaussian parameter with low-rank structure.
Assumes the covariance is factorized as a product of a matrix :math:\mathbf{S} \in \mathbb{R}^{P \times R}` and its transpose.
..math:: \mathbf{\Sigma} = \mathbf{S} \mathbf{S}^\top
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rank
|
int
|
Rank of the covariance matrix. If |
required |
Methods:
Name | Description |
---|---|
factor_matmul |
Multiply left factor of the covariance matrix with the input. |
initialize_parameters |
Initialize the covariance parameters. |
reset_parameters |
Reset the parameters of the covariance matrix. |
to_dense |
Convert the covariance matrix to a dense representation. |
Attributes:
Name | Type | Description |
---|---|---|
lr_scaling |
dict[str, float]
|
Compute the learning rate scaling for the covariance parameters. |
rank |
|
lr_scaling
#
Compute the learning rate scaling for the covariance parameters.
factor_matmul
#
initialize_parameters
#
reset_parameters
#
Reset the parameters of the covariance matrix.
Initalizes the parameters of the covariance matrix with a scale that is given by the mean parameter scales and a covariance-specific scaling that depends on the structure of the covariance matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mean_parameter_scales
|
dict[str, float] | float
|
Scales of the mean parameters. If a dictionary keys are the names of the mean parameters. If a float, all covariance parameters are initialized with the same scale. |
1.0
|