Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update intro_long.ipynb #3420

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tutorial/source/intro_long.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -656,16 +656,16 @@
"```python\n",
"def param(\n",
" name: str,\n",
" init: Optional[Union[torch.Tensor, Callable[..., torch.Tensor]]] = None,\n",
" init_tensor: Optional[Union[torch.Tensor, Callable[..., torch.Tensor]]] = None,\n",
" *,\n",
" constraint: torch.distributions.constraints.Constraint = constraints.real\n",
") -> torch.Tensor:\n",
" ...\n",
"```\n",
"\n",
"Like `pyro.sample`, `pyro.param` is always called with a name as its first argument. The first time `pyro.param` is called with a particular name, it stores the initial value specified by the second argument `init` in the parameter store and then returns that value. After that, when it is called with that name, it returns the value from the parameter store regardless of any other arguments. After a parameter has been initialized, it is no longer necessary to specify `init` to retrieve its value (e.g. `pyro.param(\"a\")`).\n",
"Like `pyro.sample`, `pyro.param` is always called with a name as its first argument. The first time `pyro.param` is called with a particular name, it stores the initial value specified by the second argument `init_tensor` in the parameter store and then returns that value. After that, when it is called with that name, it returns the value from the parameter store regardless of any other arguments. After a parameter has been initialized, it is no longer necessary to specify `init_tensor` to retrieve its value (e.g. `pyro.param(\"a\")`).\n",
"\n",
"The second argument, `init`, can be either a `torch.Tensor` or a function that takes no arguments and returns a tensor. The second form is useful because it avoids repeatedly constructing initial values that are only used the first time a model is run.\n",
"The second argument, `init_tensor`, can be either a `torch.Tensor` or a function that takes no arguments and returns a tensor. The second form is useful because it avoids repeatedly constructing initial values that are only used the first time a model is run.\n",
"\n",
"Unlike PyTorch's `torch.nn.Parameter`s, parameters in Pyro can be explicitly constrained to various subsets of $\\mathbb{R}^n$, an important feature because many elementary probability distributions have parameters with restricted domains. For example, the `scale` parameter of a `Normal` distribution must be positive. The optional third argument to `pyro.param`, `constraint`, is a [torch.distributions.constraints.Constraint](https://docs.pyro.ai/en/stable/distributions.html#module-pyro.distributions.constraints) object stored when a parameter is initialized; constraints are reapplied after every update. Pyro ships with a large number of predefined constraints. \n",
"\n",
Expand Down