beginning of char-rnn example
This commit is contained in:
parent
ba78b99b86
commit
f0779fc77c
20
examples/char-rnn.jl
Normal file
20
examples/char-rnn.jl
Normal file
@ -0,0 +1,20 @@
|
||||
using Flux
|
||||
|
||||
input = readstring("$(homedir())/Downloads/shakespeare_input.txt")
|
||||
|
||||
alphabet = unique(input)
|
||||
|
||||
getseqs(data, n) = (Seq(onehot(Float32, char, alphabet) for char in chunk) for chunk in chunks(data, n))
|
||||
|
||||
data = zip(getseqs(input, 50), getseqs(input[2:end], 50))
|
||||
|
||||
model = Chain(
|
||||
Input(length(alphabet)),
|
||||
Flux.Recurrent(length(alphabet), 128, length(alphabet)),
|
||||
softmax)
|
||||
|
||||
unrolled = unroll(model, 50)
|
||||
|
||||
m = tf(unrolled)
|
||||
|
||||
Flux.train!(m, data)
|
Loading…
Reference in New Issue
Block a user