Skip to content

Commit

Permalink
final fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinuzziFrancesco committed Dec 19, 2024
1 parent 900869e commit 3b4d8d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RecurrentLayers"
uuid = "78449bcf-6750-4b78-9e82-63d4a1ccdf8c"
authors = ["Francesco Martinuzzi"]
version = "0.2.2"
version = "0.2.3"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
13 changes: 4 additions & 9 deletions src/rhn_cell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function (rhn::RHNCellUnit)(inp::AbstractVecOrMat)
end

function (rhn::RHNCellUnit)(inp::AbstractVecOrMat, state::AbstractVecOrMat)
_size_check(rhn, inp, 1 => size(rhn.weight, 2))
weight, bias = rhn.weight, rhn.bias
_size_check(rhn, inp, 1 => size(rhn.weights, 2))
weight, bias = rhn.weights, rhn.bias

#compute
pre_nonlin = weight * inp .+ bias
Expand All @@ -43,7 +43,7 @@ function (rhn::RHNCellUnit)(inp::AbstractVecOrMat, state::AbstractVecOrMat)
end

Base.show(io::IO, rhn::RHNCellUnit) =
print(io, "RHNCellUnit(", size(rhn.weight, 2), " => ", size(rhn.weight, 1)÷3, ")")
print(io, "RHNCellUnit(", size(rhn.weights, 2), " => ", size(rhn.weights, 1)÷3, ")")

struct RHNCell{C}
layers::C
Expand Down Expand Up @@ -189,10 +189,5 @@ end

function (rhn::RHN)(inp::AbstractArray, state::AbstractVecOrMat)
@assert ndims(inp) == 2 || ndims(inp) == 3
new_state = []
for inp_t in eachslice(inp, dims=2)
state = rhn.cell(inp_t, state)
new_state = vcat(new_state, [state])
end
return stack(new_state, dims=2)
return scan(rhn.cell, inp, state)
end

0 comments on commit 3b4d8d4

Please sign in to comment.