Skip to content

Commit

Permalink
Merge pull request #91 from probcomp/20240110-xiaoyan-fixing-urls
Browse files Browse the repository at this point in the history
Update links to documentation in all tutorial notebooks
  • Loading branch information
ztangent authored Jan 11, 2024
2 parents c4f7f03 + a1671c2 commit a37d248
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 52 deletions.
14 changes: 7 additions & 7 deletions tutorials/A Bottom-Up Introduction to Gen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The ability to *trace* the values of random choices in a probabilistic program (i.e. record the value of each choice in a trace data structure) is one of the basic features of Gen's built-in modeling language. To write a function in this language we use the `@gen` macro provided by Gen. Note that the built-in modeling language is just one way of defining a [generative function](https://probcomp.github.io/Gen/dev/ref/distributions/).\n",
"The ability to *trace* the values of random choices in a probabilistic program (i.e. record the value of each choice in a trace data structure) is one of the basic features of Gen's built-in modeling language. To write a function in this language we use the `@gen` macro provided by Gen. Note that the built-in modeling language is just one way of defining a [generative function](https://www.gen.dev/docs/stable/ref/distributions/).\n",
"\n",
"Below, we write a `@gen function` version of the function `f` defined above, this time using Gen's tracing instead of our own:"
]
Expand Down Expand Up @@ -2225,7 +2225,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To run a `@gen` function and get a trace of the execution, we use the [`simulate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.simulate) method:"
"To run a `@gen` function and get a trace of the execution, we use the [`simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method:"
]
},
{
Expand Down Expand Up @@ -2715,7 +2715,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also get the log probability that an individual trace would be generated by the function ($\\log p(t; x)$), using the [`get_score`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.get_score) method.\n",
"We can also get the log probability that an individual trace would be generated by the function ($\\log p(t; x)$), using the [`get_score`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.get_score) method.\n",
"\n",
"Let's generate a trace below, get its log probability with `get_score`"
]
Expand Down Expand Up @@ -2778,7 +2778,7 @@
" gen_f(0.3)\n",
" ```\n",
"\n",
"2. Using the [`simulate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.simulate) method:\n",
"2. Using the [`simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method:\n",
"\n",
" ```julia\n",
" trace = simulate(gen_f, (0.3,))\n",
Expand All @@ -2789,7 +2789,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also generate a trace that satisfies a set of constraints on the valus of random choices using the [`generate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.generate) method. Suppose that we want a trace where `:a` is always `true` and `:c` is always `false`. We first construct a choice map containing these constraints:"
"We can also generate a trace that satisfies a set of constraints on the valus of random choices using the [`generate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.generate) method. Suppose that we want a trace where `:a` is always `true` and `:c` is always `false`. We first construct a choice map containing these constraints:"
]
},
{
Expand Down Expand Up @@ -3013,7 +3013,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"A more efficient and numerically robust implementation of importance resampling is provided in Gen's inference library (see [`importance_resampling`](https://probcomp.github.io/Gen/dev/ref/inference/#Gen.importance_resampling))."
"A more efficient and numerically robust implementation of importance resampling is provided in Gen's inference library (see [`importance_resampling`](https://www.gen.dev/docs/stable/ref/inference/#Gen.importance_resampling))."
]
},
{
Expand Down Expand Up @@ -3433,7 +3433,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we use the [`update`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.update) method, to change the value of `:c` from `true` to `false`:"
"Now, we use the [`update`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.update) method, to change the value of `:c` from `true` to `false`:"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions tutorials/A Bottom-Up Introduction to Gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ plot(map(p -> query(p, 14), [0.1, 0.5, 0.9])...)

# ## 2. Tracing the values of random choices in generative functions

# The ability to *trace* the values of random choices in a probabilistic program (i.e. record the value of each choice in a trace data structure) is one of the basic features of Gen's built-in modeling language. To write a function in this language we use the `@gen` macro provided by Gen. Note that the built-in modeling language is just one way of defining a [generative function](https://probcomp.github.io/Gen/dev/ref/distributions/).
# The ability to *trace* the values of random choices in a probabilistic program (i.e. record the value of each choice in a trace data structure) is one of the basic features of Gen's built-in modeling language. To write a function in this language we use the `@gen` macro provided by Gen. Note that the built-in modeling language is just one way of defining a [generative function](https://www.gen.dev/docs/stable/ref/distributions/).
#
# Below, we write a `@gen function` version of the function `f` defined above, this time using Gen's tracing instead of our own:

Expand All @@ -210,7 +210,7 @@ end;

gen_f(0.3)

# To run a `@gen` function and get a trace of the execution, we use the [`simulate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.simulate) method:
# To run a `@gen` function and get a trace of the execution, we use the [`simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method:

using Gen: simulate
trace = simulate(gen_f, (0.3,));
Expand Down Expand Up @@ -300,7 +300,7 @@ for prob_a in [0.1, 0.5, 0.9]
println("expected: $(prob_true(prob_a)), actual: $actual")
end

# We can also get the log probability that an individual trace would be generated by the function ($\log p(t; x)$), using the [`get_score`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.get_score) method.
# We can also get the log probability that an individual trace would be generated by the function ($\log p(t; x)$), using the [`get_score`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.get_score) method.
#
# Let's generate a trace below, get its log probability with `get_score`

Expand All @@ -321,13 +321,13 @@ println("log probability: $(get_score(trace))")
# gen_f(0.3)
# ```
#
# 2. Using the [`simulate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.simulate) method:
# 2. Using the [`simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method:
#
# ```julia
# trace = simulate(gen_f, (0.3,))
# ```

# We can also generate a trace that satisfies a set of constraints on the valus of random choices using the [`generate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.generate) method. Suppose that we want a trace where `:a` is always `true` and `:c` is always `false`. We first construct a choice map containing these constraints:
# We can also generate a trace that satisfies a set of constraints on the valus of random choices using the [`generate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.generate) method. Suppose that we want a trace where `:a` is always `true` and `:c` is always `false`. We first construct a choice map containing these constraints:

# +
using Gen: choicemap
Expand Down Expand Up @@ -414,7 +414,7 @@ function my_importance_sampler(gen_fn, args, constraints, num_traces)
return traces[idx]
end;

# A more efficient and numerically robust implementation of importance resampling is provided in Gen's inference library (see [`importance_resampling`](https://probcomp.github.io/Gen/dev/ref/inference/#Gen.importance_resampling)).
# A more efficient and numerically robust implementation of importance resampling is provided in Gen's inference library (see [`importance_resampling`](https://www.gen.dev/docs/stable/ref/inference/#Gen.importance_resampling)).

# Suppose our goal is to sample `:a` and `:b` from the conditional distribution given that we have observed `:c` is `false`. That is, we want to sample choice map $t$ with probability $0$ if $t(c) = \mbox{false}$ and otherwise probability:
#
Expand Down Expand Up @@ -473,7 +473,7 @@ plot(map(N -> importance_query(0.3, N), [1, 10, 100])...)
(trace, weight) = generate(foo, (0.3,), choicemap((:a, true), (:b, true), (:c, true)));
get_choices(trace)

# Now, we use the [`update`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.update) method, to change the value of `:c` from `true` to `false`:
# Now, we use the [`update`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.update) method, to change the value of `:c` from `true` to `false`:

# +
using Gen: update, NoChange
Expand Down
10 changes: 5 additions & 5 deletions tutorials/Data-Driven Proposals in Gen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@
"metadata": {},
"source": [
"The inference algorithm above used a variant of\n",
"[`Gen.importance_resampling`](https://probcomp.github.io/Gen/dev/ref/importance/#Gen.importance_resampling)\n",
"[`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)\n",
"that does not take a custom proposal distribution. It uses the default\n",
"proposal distribution associated with the generative model. For generative\n",
"functions defined using the built-in modeling DSL, the default proposal\n",
Expand Down Expand Up @@ -1437,7 +1437,7 @@
"metadata": {},
"source": [
"We can propose values of random choices from the proposal function using\n",
"[`Gen.propose`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.propose).\n",
"[`Gen.propose`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.propose).\n",
"This method returns the choices, as well as some other information, which we\n",
"won't need for our purposes. For now, you can think of `Gen.propose` as\n",
"similar to `Gen.generate` except that it does not produce a full execution\n",
Expand Down Expand Up @@ -1568,7 +1568,7 @@
"source": [
"We now use our data-driven proposal within an inference algorithm. There is a\n",
"second variant of\n",
"[`Gen.importance_resampling`](https://probcomp.github.io/Gen/dev/ref/importance/#Gen.importance_resampling)\n",
"[`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)\n",
"that accepts a generative function representing a custom proposal. This\n",
"proposal generative function makes traced random choices at the addresses of\n",
"a subset of the unobserved random choices made by the generative model. In\n",
Expand All @@ -1593,7 +1593,7 @@
"\n",
"This time, use only 5 importance samples (`amt_computation`). You can run\n",
"`?Gen.importance_resampling` or check out the\n",
"[documentation](https://probcomp.github.io/Gen/dev/ref/inference/#Importance-Sampling-1)\n",
"[documentation](https://www.gen.dev/docs/stable/ref/inference/#Importance-Sampling-1)\n",
"to understand how to supply the arguments to invoke this second version of of\n",
"importance resampling."
]
Expand Down Expand Up @@ -1948,7 +1948,7 @@
"metadata": {},
"source": [
"Finally, we use the\n",
"[`Gen.train!`](https://probcomp.github.io/Gen/dev/ref/inference/#Gen.train!)\n",
"[`Gen.train!`](https://www.gen.dev/docs/stable/ref/inference/#Gen.train!)\n",
"method to actually do the training.\n",
"\n",
"For each epoch, `Gen.train!` makes `epoch_size` calls to the data-generator\n",
Expand Down
10 changes: 5 additions & 5 deletions tutorials/Data-Driven Proposals in Gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ visualize_inference(measurements, scene_2doors, start, computation_amt=100, samp
# ## 2. Writing a data-driven proposal as a generative function <a name="custom-proposal"></a>

# The inference algorithm above used a variant of
# [`Gen.importance_resampling`](https://probcomp.github.io/Gen/dev/ref/importance/#Gen.importance_resampling)
# [`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)
# that does not take a custom proposal distribution. It uses the default
# proposal distribution associated with the generative model. For generative
# functions defined using the built-in modeling DSL, the default proposal
Expand Down Expand Up @@ -676,7 +676,7 @@ compute_bin_probs(num_y_bins, scene.ymin, scene.ymax, measurements[1].y, measure
end;

# We can propose values of random choices from the proposal function using
# [`Gen.propose`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.propose).
# [`Gen.propose`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.propose).
# This method returns the choices, as well as some other information, which we
# won't need for our purposes. For now, you can think of `Gen.propose` as
# similar to `Gen.generate` except that it does not produce a full execution
Expand Down Expand Up @@ -723,7 +723,7 @@ visualize_custom_destination_proposal(measurements, start, custom_dest_proposal,

# We now use our data-driven proposal within an inference algorithm. There is a
# second variant of
# [`Gen.importance_resampling`](https://probcomp.github.io/Gen/dev/ref/importance/#Gen.importance_resampling)
# [`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)
# that accepts a generative function representing a custom proposal. This
# proposal generative function makes traced random choices at the addresses of
# a subset of the unobserved random choices made by the generative model. In
Expand All @@ -742,7 +742,7 @@ visualize_custom_destination_proposal(measurements, start, custom_dest_proposal,
#
# This time, use only 5 importance samples (`amt_computation`). You can run
# `?Gen.importance_resampling` or check out the
# [documentation](https://probcomp.github.io/Gen/dev/ref/inference/#Importance-Sampling-1)
# [documentation](https://www.gen.dev/docs/stable/ref/inference/#Importance-Sampling-1)
# to understand how to supply the arguments to invoke this second version of of
# importance resampling.

Expand Down Expand Up @@ -933,7 +933,7 @@ end;
update = Gen.ParamUpdate(Gen.FixedStepGradientDescent(0.001), custom_dest_proposal_trainable);

# Finally, we use the
# [`Gen.train!`](https://probcomp.github.io/Gen/dev/ref/inference/#Gen.train!)
# [`Gen.train!`](https://www.gen.dev/docs/stable/ref/inference/#Gen.train!)
# method to actually do the training.
#
# For each epoch, `Gen.train!` makes `epoch_size` calls to the data-generator
Expand Down
10 changes: 5 additions & 5 deletions tutorials/Introduction to Modeling in Gen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"Generative functions are used to represent a variety of different types of\n",
"probabilistic computations including generative models, inference models,\n",
"custom proposal distributions, and variational approximations (see the [Gen\n",
"documentation](https://probcomp.github.io/Gen/dev/ref/gfi/) or the \n",
"documentation](https://www.gen.dev/docs/stable/ref/gfi/) or the \n",
"[paper](https://dl.acm.org/doi/10.1145/3314221.3314642)). In this\n",
"tutorial,\n",
"we focus on implementing _generative models_. A generative model represents\n",
Expand All @@ -234,7 +234,7 @@
"\n",
"\n",
"The simplest way to construct a generative function is by using the [built-in\n",
"modeling DSL](https://probcomp.github.io/Gen/dev/ref/modeling/). Generative\n",
"modeling DSL](https://www.gen.dev/docs/stable/ref/modeling/). Generative\n",
"functions written in the built-in modeling DSL are based on Julia function\n",
"definition syntax, but are prefixed with the `@gen` macro:\n",
"\n",
Expand Down Expand Up @@ -425,7 +425,7 @@
"Although the random choices are not included in the return value, they *are*\n",
"included in the *execution trace* of the generative function. We can run the\n",
"generative function and obtain its trace using the [`\n",
"simulate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.simulate) method\n",
"simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method\n",
"from the Gen API:"
]
},
Expand Down Expand Up @@ -3228,10 +3228,10 @@
"x-coordinates by adding noise to the value of the wave at each x-coordinate.\n",
"Use a `gamma(1, 1)` prior distribution for the period, and a `gamma(1, 1)`\n",
"prior distribution on the amplitude (see\n",
"[`Gen.gamma`](https://probcomp.github.io/Gen/dev/ref/distributions/#Gen.gamma)).\n",
"[`Gen.gamma`](https://www.gen.dev/docs/stable/ref/distributions/#Gen.gamma)).\n",
"Sampling from a Gamma distribution will ensure to give us postive real values.\n",
"Use a uniform distribution between 0 and $2\\pi$ for the phase (see\n",
"[`Gen.uniform`](https://probcomp.github.io/Gen/dev/ref/distributions/#Gen.uniform)).\n",
"[`Gen.uniform`](https://www.gen.dev/docs/stable/ref/distributions/#Gen.uniform)).\n",
"\n",
"The sine wave should implement:\n",
"\n",
Expand Down
10 changes: 5 additions & 5 deletions tutorials/Introduction to Modeling in Gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ typeof("foo")
# Generative functions are used to represent a variety of different types of
# probabilistic computations including generative models, inference models,
# custom proposal distributions, and variational approximations (see the [Gen
# documentation](https://probcomp.github.io/Gen/dev/ref/gfi/) or the
# documentation](https://www.gen.dev/docs/stable/ref/gfi/) or the
# [paper](https://dl.acm.org/doi/10.1145/3314221.3314642)). In this
# tutorial,
# we focus on implementing _generative models_. A generative model represents
Expand All @@ -129,7 +129,7 @@ typeof("foo")
#
#
# The simplest way to construct a generative function is by using the [built-in
# modeling DSL](https://probcomp.github.io/Gen/dev/ref/modeling/). Generative
# modeling DSL](https://www.gen.dev/docs/stable/ref/modeling/). Generative
# functions written in the built-in modeling DSL are based on Julia function
# definition syntax, but are prefixed with the `@gen` macro:
#
Expand Down Expand Up @@ -268,7 +268,7 @@ y = line_model(xs)
# Although the random choices are not included in the return value, they *are*
# included in the *execution trace* of the generative function. We can run the
# generative function and obtain its trace using the [`
# simulate`](https://probcomp.github.io/Gen/dev/ref/gfi/#Gen.simulate) method
# simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method
# from the Gen API:

trace = Gen.simulate(line_model, (xs,));
Expand Down Expand Up @@ -354,10 +354,10 @@ grid(render_trace, traces)
# x-coordinates by adding noise to the value of the wave at each x-coordinate.
# Use a `gamma(1, 1)` prior distribution for the period, and a `gamma(1, 1)`
# prior distribution on the amplitude (see
# [`Gen.gamma`](https://probcomp.github.io/Gen/dev/ref/distributions/#Gen.gamma)).
# [`Gen.gamma`](https://www.gen.dev/docs/stable/ref/distributions/#Gen.gamma)).
# Sampling from a Gamma distribution will ensure to give us postive real values.
# Use a uniform distribution between 0 and $2\pi$ for the phase (see
# [`Gen.uniform`](https://probcomp.github.io/Gen/dev/ref/distributions/#Gen.uniform)).
# [`Gen.uniform`](https://www.gen.dev/docs/stable/ref/distributions/#Gen.uniform)).
#
# The sine wave should implement:
#
Expand Down
2 changes: 1 addition & 1 deletion tutorials/Iterative inference in Gen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3732,7 +3732,7 @@
"`is_outlier` score to the most likely possibility. We can do this by\n",
"iterating over both possible traces, scoring them, and choosing the one with\n",
"the higher score. We can do this using Gen's\n",
"[`update`](https://probcomp.github.io/Gen/dev/ref/gfi/#Update-1) function,\n",
"[`update`](https://www.gen.dev/docs/stable/ref/gfi/#Update-1) function,\n",
"which allows us to manually update a trace to satisfy some constraints:"
]
},
Expand Down
2 changes: 1 addition & 1 deletion tutorials/Iterative inference in Gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ gif(viz)
# `is_outlier` score to the most likely possibility. We can do this by
# iterating over both possible traces, scoring them, and choosing the one with
# the higher score. We can do this using Gen's
# [`update`](https://probcomp.github.io/Gen/dev/ref/gfi/#Update-1) function,
# [`update`](https://www.gen.dev/docs/stable/ref/gfi/#Update-1) function,
# which allows us to manually update a trace to satisfy some constraints:

function is_outlier_map_update(tr)
Expand Down
Loading

0 comments on commit a37d248

Please sign in to comment.