-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove Flux.params from tests broken deprecation in __old_to_new pen2 remove params entirely export Optimisers cleanup fix ambiguity comment
- Loading branch information
1 parent
7525499
commit 5bdf443
Showing
18 changed files
with
211 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
@testset "RNN" begin | ||
@testset for R in [RNN, GRU, LSTM, GRUv3], batch_size in (1, 5) | ||
rnn = R(10, 5) | ||
curnn = rnn |> gpu | ||
|
||
Flux.reset!(rnn) | ||
Flux.reset!(curnn) | ||
x = batch_size == 1 ? | ||
rand(Float32, 10) : | ||
rand(Float32, 10, batch_size) | ||
cux = gpu(x) | ||
|
||
y, back = pullback((r, x) -> r(x), rnn, x) | ||
cuy, cuback = pullback((r, x) -> r(x), curnn, cux) | ||
|
||
@test y ≈ collect(cuy) | ||
|
||
ȳ = randn(size(y)) | ||
m̄, x̄ = back(ȳ) | ||
cum̄, cux̄ = cuback(gpu(ȳ)) | ||
|
||
@test x̄ ≈ collect(cux̄) | ||
@test m̄[].cell.Wi ≈ collect(cum̄[].cell.Wi) | ||
@test m̄[].cell.Wh ≈ collect(cum̄[].cell.Wh) | ||
@test m̄[].cell.b ≈ collect(cum̄[].cell.b) | ||
if m̄[].state isa Tuple | ||
for (x, cx) in zip(m̄[].state, cum̄[].state) | ||
@test x ≈ collect(cx) | ||
end | ||
else | ||
@test m̄[].state ≈ collect(cum̄[].state) | ||
end | ||
|
||
Flux.reset!(rnn) | ||
Flux.reset!(curnn) | ||
ohx = batch_size == 1 ? | ||
Flux.onehot(rand(1:10), 1:10) : | ||
Flux.onehotbatch(rand(1:10, batch_size), 1:10) | ||
cuohx = gpu(ohx) | ||
y = (rnn(ohx); rnn(ohx)) | ||
|
||
cuy = (curnn(cuohx); curnn(cuohx)) | ||
@test y ≈ collect(cuy) | ||
|
||
Flux.reset!(rnn) | ||
Flux.reset!(curnn) | ||
fx = rand(Float32, 10, batch_size, 3) | ||
cufx = gpu(fx) | ||
fy = (rnn(fx); rnn(fx)) | ||
|
||
cufy = (curnn(cufx); curnn(cufx)) | ||
@test fy ≈ collect(cufy) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.