Skip to content

Commit

Permalink
fix docstring, up flux and version
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinuzziFrancesco committed Dec 15, 2024
1 parent 01de229 commit bebd3b2
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 112 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name = "RecurrentLayers"
uuid = "78449bcf-6750-4b78-9e82-63d4a1ccdf8c"
authors = ["Francesco Martinuzzi"]
version = "0.1.5"
version = "0.2.0"

[deps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"

[compat]
Flux = "0.14, 0.15"
Flux = "0.16"
julia = "1.10"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pages=[
"Home" => "index.md",
"API Documentation" => [
"Cells" => "api/cells.md",
"Cell Wrappers" => "api/wrappers.md",
"Layers" => "api/layers.md",
],
"Roadmap" => "roadmap.md"
]
File renamed without changes.
39 changes: 22 additions & 17 deletions src/fastrnn_cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ h_t &= \alpha \tilde{h}_t + \beta h_{t-1}
# Forward
fastrnncell(inp, [state])
The arguments of the forward pass are:
fastrnncell(inp, state)
fastrnncell(inp)
## Arguments
- `inp`: The input to the fastrnncell. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the FastRNN. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- A tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
"""
function FastRNNCell((input_size, hidden_size)::Pair, activation=tanh_fast;
init_kernel = glorot_uniform,
Expand Down Expand Up @@ -113,17 +114,18 @@ h_t &= \alpha \tilde{h}_t + \beta h_{t-1}
# Forward
fastrnn(inp, [state])
The arguments of the forward pass are:
fastrnn(inp, state)
fastrnn(inp)
## Arguments
- `inp`: The input to the fastrnn. It should be a vector of size `input_size x len`
or a matrix of size `input_size x len x batch_size`.
- `state`: The hidden state of the FastRNN. If given, it is a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns new hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
## Returns
- New hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
"""
function FastRNN((input_size, hidden_size)::Pair, activation = tanh_fast;
kwargs...)
Expand Down Expand Up @@ -176,18 +178,20 @@ h_t &= \big((\zeta (1 - z_t) + \nu) \odot \tilde{h}_t\big) + z_t \odot h_{t-1}
# Forward
fastgrnncell(inp, [state])
fastgrnncell(inp, state)
fastgrnncell(inp)
The arguments of the forward pass are:
## Arguments
- `inp`: The input to the fastgrnncell. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the FastGRNN. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- A tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
"""
function FastGRNNCell((input_size, hidden_size)::Pair, activation=tanh_fast;
init_kernel = glorot_uniform,
Expand Down Expand Up @@ -257,18 +261,19 @@ h_t &= \big((\zeta (1 - z_t) + \nu) \odot \tilde{h}_t\big) + z_t \odot h_{t-1}
# Forward
fastgrnn(inp, [state])
fastgrnn(inp, state)
fastgrnn(inp)
The arguments of the forward pass are:
## Arguments
- `inp`: The input to the fastgrnn. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the FastGRNN. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- New hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
"""
function FastGRNN((input_size, hidden_size)::Pair, activation = tanh_fast;
kwargs...)
Expand Down
20 changes: 11 additions & 9 deletions src/indrnn_cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ See [`IndRNN`](@ref) for a layer that processes entire sequences.
# Forward
indrnncell(inp, [state])
The arguments of the forward pass are:
indrnncell(inp, state)
indrnncell(inp)
## Arguments
- `inp`: The input to the indrnncell. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the IndRNNCell. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- A tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
"""
function IndRNNCell((input_size, hidden_size)::Pair, σ=relu;
init_kernel = glorot_uniform,
Expand Down Expand Up @@ -96,17 +97,18 @@ See [`IndRNNCell`](@ref) for a layer that processes a single sequence.
```
# Forward
indrnn(inp, [state])
The arguments of the forward pass are:
indrnn(inp, state)
indrnn(inp)
## Arguments
- `inp`: The input to the indrnn. It should be a vector of size `input_size x len`
or a matrix of size `input_size x len x batch_size`.
- `state`: The hidden state of the IndRNN. If given, it is a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns new hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
## Returns
- New hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
"""
function IndRNN((input_size, hidden_size)::Pair, σ = tanh; kwargs...)
cell = IndRNNCell(input_size, hidden_size, σ; kwargs...)
Expand Down
20 changes: 11 additions & 9 deletions src/lightru_cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ h_t &= (1 - f_t) \odot h_{t-1} + f_t \odot \tilde{h}_t.
# Forward
lightrucell(inp, [state])
The arguments of the forward pass are:
lightrucell(inp, state)
lightrucell(inp)
## Arguments
- `inp`: The input to the lightrucell. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the LightRUCell. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- A tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
"""
function LightRUCell((input_size, hidden_size)::Pair;
init_kernel = glorot_uniform,
Expand Down Expand Up @@ -107,17 +108,18 @@ h_t &= (1 - f_t) \odot h_{t-1} + f_t \odot \tilde{h}_t.
# Forward
lightru(inp, [state])
The arguments of the forward pass are:
lightru(inp, state)
lightru(inp)
## Arguments
- `inp`: The input to the lightru. It should be a vector of size `input_size x len`
or a matrix of size `input_size x len x batch_size`.
- `state`: The hidden state of the LightRU. If given, it is a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns new hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
## Returns
- New hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
"""
function LightRU((input_size, hidden_size)::Pair; kwargs...)
cell = LightRUCell(input_size => hidden_size; kwargs...)
Expand Down
20 changes: 11 additions & 9 deletions src/ligru_cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ h_t &= z_t \odot h_{t-1} + (1 - z_t) \odot \tilde{h}_t
# Forward
ligrucell(inp, [state])
The arguments of the forward pass are:
ligrucell(inp, state)
ligrucell(inp)
## Arguments
- `inp`: The input to the ligrucell. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the LiGRUCell. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- A tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
"""
function LiGRUCell((input_size, hidden_size)::Pair;
init_kernel = glorot_uniform,
Expand Down Expand Up @@ -107,17 +108,18 @@ h_t &= z_t \odot h_{t-1} + (1 - z_t) \odot \tilde{h}_t
# Forward
ligru(inp, [state])
The arguments of the forward pass are:
ligru(inp, state)
ligru(inp)
## Arguments
- `inp`: The input to the ligru. It should be a vector of size `input_size x len`
or a matrix of size `input_size x len x batch_size`.
- `state`: The hidden state of the LiGRU. If given, it is a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns new hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
## Returns
- New hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
"""
function LiGRU((input_size, hidden_size)::Pair; kwargs...)
cell = LiGRUCell(input_size => hidden_size; kwargs...)
Expand Down
20 changes: 11 additions & 9 deletions src/mgu_cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ h_t &= (1 - f_t) \odot h_{t-1} + f_t \odot \tilde{h}_t
# Forward
mgucell(inp, [state])
The arguments of the forward pass are:
mgucell(inp, state)
mgucell(inp)
## Arguments
- `inp`: The input to the mgucell. It should be a vector of size `input_size`
or a matrix of size `input_size x batch_size`.
- `state`: The hidden state of the MGUCell. It should be a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns a tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
## Returns
- A tuple `(output, state)`, where both elements are given by the updated state `new_state`,
a tensor of size `hidden_size` or `hidden_size x batch_size`.
"""
function MGUCell((input_size, hidden_size)::Pair;
init_kernel = glorot_uniform,
Expand Down Expand Up @@ -106,17 +107,18 @@ h_t &= (1 - f_t) \odot h_{t-1} + f_t \odot \tilde{h}_t
# Forward
mgu(inp, [state])
The arguments of the forward pass are:
mgu(inp, state)
mgu(inp)
## Arguments
- `inp`: The input to the mgu. It should be a vector of size `input_size x len`
or a matrix of size `input_size x len x batch_size`.
- `state`: The hidden state of the MGU. If given, it is a vector of size
`hidden_size` or a matrix of size `hidden_size x batch_size`.
If not provided, it is assumed to be a vector of zeros.
Returns new hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
## Returns
- New hidden states `new_states` as an array of size `hidden_size x len x batch_size`.
"""
function MGU((input_size, hidden_size)::Pair; kwargs...)
cell = MGUCell(input_size => hidden_size; kwargs...)
Expand Down
Loading

0 comments on commit bebd3b2

Please sign in to comment.