torch_openreml.covariance.simple_param_specs¶
- torch_openreml.covariance.simple_param_specs(n, default=0.0, trans=None)[source]¶
Create a parameter specification dictionary with
nparameters.Each parameter is named
"theta_0","theta_1", …, is not fixed, and uses a common transform for all parameters. An optional scalar default value can be provided.- Parameters:
n (int) – Number of parameters to create.
default (float or torch.Tensor, optional) – Default value for each parameter. If a tensor, it must be 1D with shape
(1,). Defaults to0.0.trans (Transform, optional) – Transform to apply to all parameters. Defaults to
TransformIdentity(unconstrained).
- Returns:
A dictionary mapping parameter names to specification dicts of the form
{"fixed": False, "default": tensor, "trans": trans}.- Return type:
dict
- Raises:
ValueError – If
defaultis a tensor without shape(1,).TypeError – If
defaultis not a float, int, or 1D tensor.
Example:
from torch_openreml.covariance.param import simple_param_specs simple_param_specs(3)
{'theta_0': {'fixed': False, 'default': tensor([0.]), 'trans': TransformIdentity()}, 'theta_1': {'fixed': False, 'default': tensor([0.]), 'trans': TransformIdentity()}, 'theta_2': {'fixed': False, 'default': tensor([0.]), 'trans': TransformIdentity()}}