Parameters¶
-
param([options])¶ Retrieves the value of a parameter by name. The parameter is created if it does not already exist.
The following options are supported:
-
dims When
dimsis given,paramreturns a tensor of dimensiondims. In this casedimsshould be an array.When
dimsis omitted,paramreturns a scalar.
-
init A function that computes the initial value of the parameter. The function is passed the dimension of a tensor as its only argument, and should return a tensor of that dimension.
When
initis omitted, the parameter is initialized with a draw from the Gaussian distribution described by themuandsigmaoptions.
-
mu The mean of the Gaussian distribution from which the initial parameter value is drawn when
initis omitted.Default:
0
-
sigma The standard deviation of the Gaussian distribution from which the initial parameter value is drawn when
initis omitted. Specify a standard deviation of0to deterministically initialize the parameter tomu.Default:
0.1
-
name The name of the parameter to retrieve. If
nameis omitted a default name is automatically generated based on the current stack address, relative to the current coroutine.
Examples:
param() param({name: 'myparam'}) param({mu: 0, sigma: 0.01, name: 'myparam'}) param({dims: [10, 10]}) param({dims: [2, 1], init: function(dims) { return ones(dims); }})
-
-
modelParam([options])¶ An analog of
paramused to create or retrieve a parameter that can be used directly in the model.Optimizing the ELBO yields maximum likelihood estimation for model parameters.
modelParamcannot be used with other inference strategies as it does not have an interpretation in the fully Bayesian setting. Attempting to do so will raise an exception.modelParamsupports the same options asparam. See the documentation for param for details.