@@ -14,45 +14,52 @@ You can modify the list of AD types in `main.jl`.
14
14
15
15
You can modify the list of models by adding a new file, ` models/{model_name}.jl ` .
16
16
17
- Ideally, ` model_name ` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
18
- However, if necessary, you can add further explanatory comments inside the model definition file.
19
-
20
17
The basic structure of this file should look like this, where ` model_name ` is replaced accordingly:
21
18
22
19
``` julia
23
20
#=
24
- You can add any explanatory comments here if necessary
21
+ (1) You can add any explanatory comments here if necessary
25
22
=#
26
23
27
- # Imports if necessary
24
+ # (2) Imports if necessary
28
25
using MyOtherPackage: some_function
29
26
30
- # Define data if necessary
27
+ # (3) Define data if necessary
31
28
data = ...
32
29
30
+ # (4) Define the model
33
31
@model function model_name (data, ... )
34
32
# Define your model here
35
33
...
36
34
end
37
35
38
- # Instantiate the model
36
+ # (5) Instantiate the model
39
37
model = model_name (data, ... )
40
38
```
41
39
42
- ** Dependencies**
40
+ ** (1) Model name**
41
+
42
+ Ideally, ` model_name ` would be self-explanatory, i.e. it would serve to illustrate exactly one feature and the name would indicate this.
43
+ However, if necessary, you can add further explanatory comments inside the model definition file.
44
+
45
+ ** (2) Dependencies**
43
46
44
47
Inside this file, you do not need to call ` using Turing ` or any of the AD backends.
45
48
(This also means you do not need to import anything that Turing re-exports, such as distributions.)
46
49
47
50
However, you will have to make sure to import any other packages that your model requires.
48
51
(If this package is not already present in the project environment, you will also have to add it to ` Project.toml ` .)
49
52
50
- ** Model definition and creation **
53
+ ** (3) Data definition **
51
54
52
55
Each file in ` models/ ` is evaluated within its own module, so you can declare data variables, etc. without worrying about name clashes.
53
56
57
+ ** (4) Model definition**
58
+
54
59
Models can be defined as usual with ` @model function model_name(...) ` .
55
60
61
+ ** (5) Model instantiation**
62
+
56
63
The last line in the file should be the creation of the Turing model object using ` model = model_name(...) ` .
57
64
(It is mandatory for the model object to be called ` model ` .)
58
65
0 commit comments