Skip to content

Commit 4d3f97e

Browse files
authored
Merge pull request #96 from probcomp/20260311-fsaad-links
Fix #88: Links to documentation are broken in the tutorials
2 parents a37d248 + 188ff16 commit 4d3f97e

18 files changed

Lines changed: 82 additions & 82 deletions

tutorials/A Bottom-Up Introduction to Gen.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@
21702170
"cell_type": "markdown",
21712171
"metadata": {},
21722172
"source": [
2173-
"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",
2173+
"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/modeling/distributions/#distributions).\n",
21742174
"\n",
21752175
"Below, we write a `@gen function` version of the function `f` defined above, this time using Gen's tracing instead of our own:"
21762176
]
@@ -2225,7 +2225,7 @@
22252225
"cell_type": "markdown",
22262226
"metadata": {},
22272227
"source": [
2228-
"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:"
2228+
"To run a `@gen` function and get a trace of the execution, we use the [`simulate`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.simulate) method:"
22292229
]
22302230
},
22312231
{
@@ -2715,7 +2715,7 @@
27152715
"cell_type": "markdown",
27162716
"metadata": {},
27172717
"source": [
2718-
"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",
2718+
"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/core/gfi/#Gen.get_score) method.\n",
27192719
"\n",
27202720
"Let's generate a trace below, get its log probability with `get_score`"
27212721
]
@@ -2778,7 +2778,7 @@
27782778
" gen_f(0.3)\n",
27792779
" ```\n",
27802780
"\n",
2781-
"2. Using the [`simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method:\n",
2781+
"2. Using the [`simulate`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.simulate) method:\n",
27822782
"\n",
27832783
" ```julia\n",
27842784
" trace = simulate(gen_f, (0.3,))\n",
@@ -2789,7 +2789,7 @@
27892789
"cell_type": "markdown",
27902790
"metadata": {},
27912791
"source": [
2792-
"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:"
2792+
"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/core/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:"
27932793
]
27942794
},
27952795
{
@@ -3013,7 +3013,7 @@
30133013
"cell_type": "markdown",
30143014
"metadata": {},
30153015
"source": [
3016-
"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))."
3016+
"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/importance/#Gen.importance_sampling)."
30173017
]
30183018
},
30193019
{
@@ -3433,7 +3433,7 @@
34333433
"cell_type": "markdown",
34343434
"metadata": {},
34353435
"source": [
3436-
"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`:"
3436+
"Now, we use the [`update`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.update) method, to change the value of `:c` from `true` to `false`:"
34373437
]
34383438
},
34393439
{

tutorials/A Bottom-Up Introduction to Gen.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ plot(map(p -> query(p, 14), [0.1, 0.5, 0.9])...)
188188

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

191-
# 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/).
191+
# 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/modeling/distributions/#distributions).
192192
#
193193
# Below, we write a `@gen function` version of the function `f` defined above, this time using Gen's tracing instead of our own:
194194

@@ -210,7 +210,7 @@ end;
210210

211211
gen_f(0.3)
212212

213-
# 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:
213+
# To run a `@gen` function and get a trace of the execution, we use the [`simulate`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.simulate) method:
214214

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

303-
# 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.
303+
# 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/core/gfi/#Gen.get_score) method.
304304
#
305305
# Let's generate a trace below, get its log probability with `get_score`
306306

@@ -321,13 +321,13 @@ println("log probability: $(get_score(trace))")
321321
# gen_f(0.3)
322322
# ```
323323
#
324-
# 2. Using the [`simulate`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.simulate) method:
324+
# 2. Using the [`simulate`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.simulate) method:
325325
#
326326
# ```julia
327327
# trace = simulate(gen_f, (0.3,))
328328
# ```
329329

330-
# 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:
330+
# 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/core/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:
331331

332332
# +
333333
using Gen: choicemap
@@ -414,7 +414,7 @@ function my_importance_sampler(gen_fn, args, constraints, num_traces)
414414
return traces[idx]
415415
end;
416416

417-
# 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)).
417+
# 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/importance/#Gen.importance_sampling).
418418

419419
# 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:
420420
#
@@ -473,7 +473,7 @@ plot(map(N -> importance_query(0.3, N), [1, 10, 100])...)
473473
(trace, weight) = generate(foo, (0.3,), choicemap((:a, true), (:b, true), (:c, true)));
474474
get_choices(trace)
475475

476-
# 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`:
476+
# Now, we use the [`update`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.update) method, to change the value of `:c` from `true` to `false`:
477477

478478
# +
479479
using Gen: update, NoChange

tutorials/Data-Driven Proposals in Gen.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@
909909
"\n",
910910
"To see how to use the built-in importance resampling function, run\n",
911911
"```?Gen.importance_resampling``` or check out the\n",
912-
"[documentation](https://www.gen.dev/docs/dev/ref/importance/#Gen.importance_resampling)."
912+
"[documentation](https://www.gen.dev/docs/stable/ref/inference/importance/#Gen.importance_resampling)."
913913
]
914914
},
915915
{
@@ -1213,7 +1213,7 @@
12131213
"metadata": {},
12141214
"source": [
12151215
"The inference algorithm above used a variant of\n",
1216-
"[`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)\n",
1216+
"[`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/inference/importance/#Gen.importance_sampling)\n",
12171217
"that does not take a custom proposal distribution. It uses the default\n",
12181218
"proposal distribution associated with the generative model. For generative\n",
12191219
"functions defined using the built-in modeling DSL, the default proposal\n",
@@ -1319,7 +1319,7 @@
13191319
"metadata": {},
13201320
"source": [
13211321
"We will propose the x-coordinate of the destination from a\n",
1322-
"[piecewise_uniform](https://www.gen.dev/docs/dev/ref/distributions/#Gen.piecewise_uniform)\n",
1322+
"[piecewise_uniform](https://www.gen.dev/docs/stable/ref/modeling/distributions/#Gen.piecewise_uniform)\n",
13231323
"distribution, where we set higher probability for certain bins based on the\n",
13241324
"heuristic described above and use a uniform continuous distribution for the\n",
13251325
"coordinate within a bin. The `compute_bin_probs` function below computes the\n",
@@ -1437,7 +1437,7 @@
14371437
"metadata": {},
14381438
"source": [
14391439
"We can propose values of random choices from the proposal function using\n",
1440-
"[`Gen.propose`](https://www.gen.dev/docs/stable/ref/gfi/#Gen.propose).\n",
1440+
"[`Gen.propose`](https://www.gen.dev/docs/stable/ref/core/gfi/#Gen.propose).\n",
14411441
"This method returns the choices, as well as some other information, which we\n",
14421442
"won't need for our purposes. For now, you can think of `Gen.propose` as\n",
14431443
"similar to `Gen.generate` except that it does not produce a full execution\n",
@@ -1568,7 +1568,7 @@
15681568
"source": [
15691569
"We now use our data-driven proposal within an inference algorithm. There is a\n",
15701570
"second variant of\n",
1571-
"[`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)\n",
1571+
"[`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/inference/importance/#Gen.importance_resampling)\n",
15721572
"that accepts a generative function representing a custom proposal. This\n",
15731573
"proposal generative function makes traced random choices at the addresses of\n",
15741574
"a subset of the unobserved random choices made by the generative model. In\n",
@@ -1593,7 +1593,7 @@
15931593
"\n",
15941594
"This time, use only 5 importance samples (`amt_computation`). You can run\n",
15951595
"`?Gen.importance_resampling` or check out the\n",
1596-
"[documentation](https://www.gen.dev/docs/stable/ref/inference/#Importance-Sampling-1)\n",
1596+
"[documentation](https://www.gen.dev/docs/stable/ref/inference/importance/#Gen.importance_sampling)\n",
15971597
"to understand how to supply the arguments to invoke this second version of of\n",
15981598
"importance resampling."
15991599
]
@@ -1774,7 +1774,7 @@
17741774
"source": [
17751775
"Our choice of the `score_high` value of 5. was somewhat arbitrary. To use\n",
17761776
"more informed value, we can make `score_high` into a [*trainable\n",
1777-
"parameter*](https://www.gen.dev/docs/dev/ref/gfi/#Trainable-parameters-1)\n",
1777+
"parameter*](https://www.gen.dev/docs/stable/ref/modeling/dml/#trainable_parameters_modeling)\n",
17781778
"of the generative function. Below, we write a new version of the proposal\n",
17791779
"function that makes `score_high` trainable. However, the optimization\n",
17801780
"algorithms we will use for training work best with *unconstrained* parameters\n",
@@ -1928,7 +1928,7 @@
19281928
"Next, we choose type of optimization algorithm we will use for training. Gen\n",
19291929
"supports a set of gradient-based optimization algorithms (see [Optimizing\n",
19301930
"Trainable\n",
1931-
"Parameters](https://www.gen.dev/docs/dev/ref/parameter_optimization/#Optimizing-Trainable-Parameters-1)).\n",
1931+
"Parameters](https://www.gen.dev/docs/stable/ref/inference/parameter_optimization/#Parameter-Optimization)).\n",
19321932
"Here we will use gradient descent with a fixed step size of 0.001."
19331933
]
19341934
},
@@ -1948,7 +1948,7 @@
19481948
"metadata": {},
19491949
"source": [
19501950
"Finally, we use the\n",
1951-
"[`Gen.train!`](https://www.gen.dev/docs/stable/ref/inference/#Gen.train!)\n",
1951+
"[`Gen.train!`](https://www.gen.dev/docs/stable/ref/inference/parameter_optimization/#Gen.train!)\n",
19521952
"method to actually do the training.\n",
19531953
"\n",
19541954
"For each epoch, `Gen.train!` makes `epoch_size` calls to the data-generator\n",

tutorials/Data-Driven Proposals in Gen.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ measurements = [
390390
#
391391
# To see how to use the built-in importance resampling function, run
392392
# ```?Gen.importance_resampling``` or check out the
393-
# [documentation](https://www.gen.dev/docs/dev/ref/importance/#Gen.importance_resampling).
393+
# [documentation](https://www.gen.dev/docs/stable/ref/inference/importance/#Gen.importance_resampling).
394394

395395
# We have provided some starter code.
396396

@@ -556,7 +556,7 @@ visualize_inference(measurements, scene_2doors, start, computation_amt=100, samp
556556
# ## 2. Writing a data-driven proposal as a generative function <a name="custom-proposal"></a>
557557

558558
# The inference algorithm above used a variant of
559-
# [`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/importance/#Gen.importance_resampling)
559+
# [`Gen.importance_resampling`](https://www.gen.dev/docs/stable/ref/inference/importance/#Gen.importance_sampling)
560560
# that does not take a custom proposal distribution. It uses the default
561561
# proposal distribution associated with the generative model. For generative
562562
# functions defined using the built-in modeling DSL, the default proposal
@@ -614,7 +614,7 @@ num_x_bins = 5
614614
num_y_bins = 5;
615615

616616
# We will propose the x-coordinate of the destination from a
617-
# [piecewise_uniform](https://www.gen.dev/docs/dev/ref/distributions/#Gen.piecewise_uniform)
617+
# [piecewise_uniform](https://www.gen.dev/docs/stable/ref/modeling/distributions/#Gen.piecewise_uniform)
618618
# distribution, where we set higher probability for certain bins based on the
619619
# heuristic described above and use a uniform continuous distribution for the
620620
# coordinate within a bin. The `compute_bin_probs` function below computes the
@@ -676,7 +676,7 @@ compute_bin_probs(num_y_bins, scene.ymin, scene.ymax, measurements[1].y, measure
676676
end;
677677

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

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

@@ -839,7 +839,7 @@ visualize_inference(measurements, scene, start, computation_amt=5, samples=1000)
839839

840840
# Our choice of the `score_high` value of 5. was somewhat arbitrary. To use
841841
# more informed value, we can make `score_high` into a [*trainable
842-
# parameter*](https://www.gen.dev/docs/dev/ref/gfi/#Trainable-parameters-1)
842+
# parameter*](https://www.gen.dev/docs/stable/ref/modeling/dml/#trainable_parameters_modeling)
843843
# of the generative function. Below, we write a new version of the proposal
844844
# function that makes `score_high` trainable. However, the optimization
845845
# algorithms we will use for training work best with *unconstrained* parameters
@@ -927,13 +927,13 @@ end;
927927
# Next, we choose type of optimization algorithm we will use for training. Gen
928928
# supports a set of gradient-based optimization algorithms (see [Optimizing
929929
# Trainable
930-
# Parameters](https://www.gen.dev/docs/dev/ref/parameter_optimization/#Optimizing-Trainable-Parameters-1)).
930+
# Parameters](https://www.gen.dev/docs/stable/ref/inference/parameter_optimization/#Parameter-Optimization)).
931931
# Here we will use gradient descent with a fixed step size of 0.001.
932932

933933
update = Gen.ParamUpdate(Gen.FixedStepGradientDescent(0.001), custom_dest_proposal_trainable);
934934

935935
# Finally, we use the
936-
# [`Gen.train!`](https://www.gen.dev/docs/stable/ref/inference/#Gen.train!)
936+
# [`Gen.train!`](https://www.gen.dev/docs/stable/ref/inference/parameter_optimization/#Gen.train!)
937937
# method to actually do the training.
938938
#
939939
# For each epoch, `Gen.train!` makes `epoch_size` calls to the data-generator

0 commit comments

Comments
 (0)