torch_openreml.covariance.simple_param_specs¶
- torch_openreml.covariance.simple_param_specs(n, default=None, 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. All parameters share the same default value.- Parameters:
n (int) – Number of parameters to create.
default (torch.Tensor, optional) – Default value for each parameter, given as a 1D tensor of shape
(1,). Defaults totorch.tensor([0.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:
TypeError – If
defaultis not a Torch tensor.ValueError – If
defaultdoes not have shape(1,).
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()}}import torch simple_param_specs(2, default=torch.tensor([1.5]))
{'theta_0': {'fixed': False, 'default': tensor([1.5000]), 'trans': TransformIdentity()}, 'theta_1': {'fixed': False, 'default': tensor([1.5000]), 'trans': TransformIdentity()}}