Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update speech-blstm to work with Flux v0.10.0 #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions contrib/audio/speech-blstm/01-speech-blstm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Networks, 18(5-6), 602-610.]).

using Flux
using Flux: crossentropy, softmax, flip, sigmoid, LSTM, @epochs
using Flux: crossentropy, softmax, sigmoid, LSTM, @epochs
using BSON
using Random

Expand All @@ -20,6 +20,11 @@ forward = LSTM(26, 93)
backward = LSTM(26, 93)
output = Dense(186, 61)

# Flux.flip blows up with "Mutating arrays not supported" error on Zygote
rev(x) = view(x, length(x):-1:1)
flip(f,x) = rev(f.(rev(x)))


"""
BLSTM(x)

Expand All @@ -33,7 +38,7 @@ is from processing it backward
# Returns
* The concatenation of the forward and backward LSTM predictions
"""
BLSTM(x) = vcat.(forward.(x), flip(backward, x))
BLSTM(x) = vcat.(forward.(x), flip(backward, x))

"""
model(x)
Expand Down Expand Up @@ -140,7 +145,8 @@ function main()
# Begin training
println("Beginning training")

opt = Momentum(params((forward, backward, output)), 10.0^-5; ρ=0.9)
ps = params((forward, backward, output))
opt = Momentum(10.0^-5, 0.9)

i = 0

Expand All @@ -151,7 +157,7 @@ function main()
shuffle!(data)
valData = valData[shuffle(1:length(valData))]

Flux.train!(loss, data, opt)
Flux.train!(loss, ps, data, opt)

BSON.@save "model_epoch$(i).bson" forward backward output

Expand Down
Loading