Skip to content

Commit b6647ad

Browse files
committed
docu
1 parent 80b1970 commit b6647ad

24 files changed

Lines changed: 37 additions & 47 deletions

docs/src/tutorials/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PairPlots = "43a3c2be-4208-490b-832a-a21dcd55d7da"
1515
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1616
SimpleChains = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5"
1717
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
18+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1819
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
1920
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
2021
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

docs/src/tutorials/basic_cpu.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ the problem below.
156156

157157
### Providing data in batches
158158

159-
HVI uses `MLUtils.DataLoader` to provide baches of the data during each
159+
HVI uses `MLUtils.DataLoader` to provide batches of the data during each
160160
iteration of the solver. In addition to the data, it provides an
161161
index to the sites inside a tuple.
162162

@@ -268,7 +268,7 @@ Then the solver is applied to the problem using [`solve`](@ref)
268268
for a given number of iterations or epochs.
269269
For this tutorial, we additionally specify that the function to transfer structures to
270270
the GPU is the identity function, so that all stays on the CPU, and this tutorial
271-
hence does not require ad GPU or GPU livraries.
271+
hence does not require ad GPU or GPU libraries.
272272

273273
Among the return values are
274274
- `probo`: A copy of the HybridProblem, with updated optimized parameters
@@ -277,7 +277,7 @@ will help analyzing the results.
277277

278278
## Using a population-level process-based model
279279

280-
So far, the process-based model ram for each single site.
280+
So far, the process-based model ran for each single site.
281281
For this simple model, some performance grains result from matrix-computations
282282
when running the model for all sites within one batch simultaneously.
283283

@@ -294,7 +294,7 @@ function f_doubleMM_sites(θc::CA.ComponentMatrix, xPc::CA.ComponentMatrix)
294294
S2 = view(xPc, Val(:S2), :)
295295
#
296296
# extract the parameters as row-repeated vectors
297-
# θc[:,:r0] is paramter r0 for each site in batch
297+
# θc[:,:r0] is parameter r0 for each site in batch
298298
# dot-multiplication of full matrix times row-vector repeats for each observation row
299299
# also introduces zero for missing observations, leading to zero gradient there
300300
is_valid = isfinite.(S1) .&& isfinite.(S2)
@@ -308,11 +308,7 @@ end
308308
```
309309

310310
Again, the function should not rely on the order of parameters but use symbolic indexing
311-
to extract the parameter vectors. For type stability of this symbolic indexing,
312-
it uses a workaround to get the type of a single row.
313-
Similarly, it uses type hints to index into the drivers, `xPc`, to extract
314-
sub-matrices by symbols. Alternatively, here it could rely on the structure and
315-
ordering of the columns in `xPc`.
311+
to extract the parameter vectors.
316312

317313
A corresponding [`PBMPopulationApplicator`](@ref) transforms calls with
318314
partitioned global and site parameters to calls of this matrix version of the PBM.
@@ -324,11 +320,9 @@ probo_sites = HybridProblem(probo; f_batch)
324320
```
325321

326322
For numerical efficiency, the number of sites within one batch is part of the
327-
`PBMPopulationApplicator`. Hence, we have two different functions, one applied
328-
to a batch of site, and another applied to all sites.
329-
330-
As a test of the new applicator, the results are refined by running a few more
331-
epochs of the optimization.
323+
`PBMPopulationApplicator`. The problem stores an applicator for `n_batch` sites,
324+
however, an applicator for `n_site_pred` sites can be obtained by
325+
`create_nsite_applicator(f_batch, n_site_pred)`.
332326

333327
``` julia
334328
(; probo) = solve(probo_sites, solver; rng,
@@ -345,7 +339,7 @@ in the following [Inspect results of fitted problem](@ref) tutorial.
345339
In order to use the results from this tutorial in other tutorials,
346340
the updated `probo` `HybridProblem` and the interpreters are saved to a JLD2 file.
347341

348-
Before the problem is updated to use the redefinition [`DoubleMM.f_doubleMM_sites`](@ref)
342+
Before the problem is updated, so that it uses the redefinition [`DoubleMM.f_doubleMM_sites`](@ref)
349343
of the PBM in module `DoubleMM` rather than
350344
module `Main` to allow for easier reloading with JLD2.
351345

docs/src/tutorials/basic_cpu.qmd

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ the problem below.
165165

166166
### Providing data in batches
167167

168-
HVI uses `MLUtils.DataLoader` to provide baches of the data during each
168+
HVI uses `MLUtils.DataLoader` to provide batches of the data during each
169169
iteration of the solver. In addition to the data, it provides an
170170
index to the sites inside a tuple.
171171

@@ -303,7 +303,7 @@ Then the solver is applied to the problem using [`solve`](@ref)
303303
for a given number of iterations or epochs.
304304
For this tutorial, we additionally specify that the function to transfer structures to
305305
the GPU is the identity function, so that all stays on the CPU, and this tutorial
306-
hence does not require ad GPU or GPU livraries.
306+
hence does not require ad GPU or GPU libraries.
307307

308308
Among the return values are
309309
- `probo`: A copy of the HybridProblem, with updated optimized parameters
@@ -312,7 +312,7 @@ Among the return values are
312312

313313
## Using a population-level process-based model
314314

315-
So far, the process-based model ram for each single site.
315+
So far, the process-based model ran for each single site.
316316
For this simple model, some performance grains result from matrix-computations
317317
when running the model for all sites within one batch simultaneously.
318318

@@ -324,13 +324,14 @@ one site. For the drivers and predictions, one column corresponds to one site.
324324

325325

326326
```{julia}
327+
using StaticArrays
327328
function f_doubleMM_sites(θc::CA.ComponentMatrix, xPc::CA.ComponentMatrix)
328329
# extract several covariates from xP
329330
S1 = view(xPc, Val(:S1), :)
330331
S2 = view(xPc, Val(:S2), :)
331332
#
332333
# extract the parameters as row-repeated vectors
333-
# θc[:,:r0] is paramter r0 for each site in batch
334+
# θc[:,:r0] is parameter r0 for each site in batch
334335
# dot-multiplication of full matrix times row-vector repeats for each observation row
335336
# also introduces zero for missing observations, leading to zero gradient there
336337
is_valid = isfinite.(S1) .&& isfinite.(S2)
@@ -344,11 +345,7 @@ end
344345
```
345346

346347
Again, the function should not rely on the order of parameters but use symbolic indexing
347-
to extract the parameter vectors. For type stability of this symbolic indexing,
348-
it uses a workaround to get the type of a single row.
349-
Similarly, it uses type hints to index into the drivers, `xPc`, to extract
350-
sub-matrices by symbols. Alternatively, here it could rely on the structure and
351-
ordering of the columns in `xPc`.
348+
to extract the parameter vectors.
352349

353350
A corresponding [`PBMPopulationApplicator`](@ref) transforms calls with
354351
partitioned global and site parameters to calls of this matrix version of the PBM.
@@ -360,11 +357,9 @@ probo_sites = HybridProblem(probo; f_batch)
360357
```
361358

362359
For numerical efficiency, the number of sites within one batch is part of the
363-
`PBMPopulationApplicator`. Hence, we have two different functions, one applied
364-
to a batch of site, and another applied to all sites.
365-
366-
As a test of the new applicator, the results are refined by running a few more
367-
epochs of the optimization.
360+
`PBMPopulationApplicator`. The problem stores an applicator for `n_batch` sites,
361+
however, an applicator for `n_site_pred` sites can be obtained by
362+
`create_nsite_applicator(f_batch, n_site_pred)`.
368363

369364
```{julia}
370365
(; probo) = solve(probo_sites, solver; rng,
@@ -380,7 +375,7 @@ in the following [Inspect results of fitted problem](@ref) tutorial.
380375
In order to use the results from this tutorial in other tutorials,
381376
the updated `probo` `HybridProblem` and the interpreters are saved to a JLD2 file.
382377

383-
Before the problem is updated to use the redefinition [`DoubleMM.f_doubleMM_sites`](@ref)
378+
Before the problem is updated, so that it uses the redefinition [`DoubleMM.f_doubleMM_sites`](@ref)
384379
of the PBM in module `DoubleMM` rather than
385380
module `Main` to allow for easier reloading with JLD2.
386381

13.3 KB
Loading
-1.11 KB
Loading
-4.78 KB
Loading
-7 Bytes
Loading
3.54 KB
Loading
-4.42 KB
Loading
547 Bytes
Loading

0 commit comments

Comments
 (0)