Skip to content

Commit 75fec04

Browse files
committed
Update docs
1 parent d74818b commit 75fec04

File tree

7 files changed

+30
-62
lines changed

7 files changed

+30
-62
lines changed

docs/make.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ makedocs(
88
sitename = "Merlin.jl",
99
pages = [
1010
"Home" => "index.md",
11+
"Var" => "var.md",
1112
"Functions" => "functions.md",
13+
"Graph" => "graph.md",
1214
"Initializaters" => "initializers.md",
13-
#"Graph" => "graph.md",
14-
#"Optimizers" => "optimizers.md",
15-
#"Save and Load" => "save_load.md",
15+
"Optimizers" => "optimizers.md",
16+
"Save and Load" => "save_load.md",
1617
]
1718
)
1819

docs/src/graph.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# Graph
2-
`Graph` is a type of computational graph.
2+
`Graph` represents a computational graph.
3+
4+
```julia
5+
using Merlin
6+
7+
T = Float32
8+
x = Node()
9+
y = Linear(T,10,7)(x)
10+
y = relu(y)
11+
y = Linear(T,7,3)(y)
12+
@assert typeof(y) == Node
13+
g = Graph(input=x, output=y)
14+
15+
x = zerograd(rand(T,10,10))
16+
y = g(x)
17+
18+
params = gradient!(y)
19+
println(x.grad)
20+
21+
opt = SGD(0.01)
22+
foreach(opt, params)
23+
```

docs/src/initializers.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,3 @@ Normal
1010
Xavier
1111
Orthogonal
1212
```
13-
14-
## Custom Initializer
15-
```julia
16-
import Merlin.random
17-
18-
struct CustomRand
19-
end
20-
21-
function random{T}(init, ::Type{T}, dims...)
22-
# code
23-
end
24-
```

docs/src/optimizers.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
# Optimizers
22

3-
A Optimizer provides functions for updating parameters.
4-
5-
For example,
63
```julia
7-
x1 = Var(rand(Float32,5,4))
8-
x1.grad = rand(Float32,5,4)
4+
x = zerograd(rand(Float32,5,4))
95
opt = SGD(0.001)
10-
opt(x1.data, x1.grad)
6+
opt(x)
117
```
128

139
```@docs

docs/src/overview.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/src/save_load.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,2 @@
11
# Save and Load
2-
`Merlin` supports saving and loading objects in HDF5 format.
3-
* For saving objects provided by Merlin, use `Merlin.save` and `Merlin.load` functions.
4-
* For other complex objects, it is recommended to use `JLD.save` and `JLD.load` functions provided by [JLD.jl](https://github.com/JuliaIO/JLD.jl).
5-
6-
```@docs
7-
Merlin.save
8-
Merlin.load
9-
```
10-
11-
For example,
12-
```julia
13-
x = Embeddings(Float32,10000,100)
14-
Merlin.save("embedding.h5", "w", "x", x)
15-
```
16-
17-
A graph structure can be saved as well:
18-
```julia
19-
T = Float32
20-
x = Var()
21-
y = Linear(T,10,7)(x)
22-
y = relu(y)
23-
y = Linear(T,7,3)(y)
24-
g = Graph(y, x)
25-
Merlin.save("graph.h5", "g", g)
26-
```
27-
28-
The saved HDF5 file is as follows:
29-
30-
![graph.h5](https://raw.githubusercontent.com/hshindo/Merlin.jl/master/docs/src/assets/graph.h5.png)
31-
32-
## Custom Serialization
33-
It requires to implement `h5convert` function for custom serialization/deserialization.
34-
See Merlin sources for details.
2+
It is recommended to use [JLD2](https://github.com/simonster/JLD2.jl) for object serialization.

docs/src/var.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Variable
1+
# Var
22

33
```@autodocs
44
Pages = ["var.jl"]

0 commit comments

Comments
 (0)