second RNN

This commit is contained in:
Jean-Marc Valin 2018-10-10 01:41:58 -04:00
parent 3698977292
commit 495f8ea5f3
3 changed files with 18 additions and 12 deletions

View file

@ -10,7 +10,8 @@ import numpy as np
import h5py
import sys
rnn_units=128
rnn_units1=128
rnn_units2=32
pcm_bits = 8
embed_size = 128
pcm_levels = 2**pcm_bits
@ -47,7 +48,8 @@ def new_wavernn_model():
feat = Input(shape=(None, nb_used_features))
pitch = Input(shape=(None, 1))
dec_feat = Input(shape=(None, 128))
dec_state = Input(shape=(rnn_units,))
dec_state1 = Input(shape=(rnn_units1,))
dec_state2 = Input(shape=(rnn_units2,))
fconv1 = Conv1D(128, 3, padding='same', activation='tanh')
fconv2 = Conv1D(102, 3, padding='same', activation='tanh')
@ -70,18 +72,21 @@ def new_wavernn_model():
rep = Lambda(lambda x: K.repeat_elements(x, 160, 1))
rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True)
rnn = CuDNNGRU(rnn_units1, return_sequences=True, return_state=True)
rnn2 = CuDNNGRU(rnn_units2, return_sequences=True, return_state=True)
rnn_in = Concatenate()([cpcm, cexc, rep(cfeat)])
md = MDense(pcm_levels, activation='softmax')
gru_out, state = rnn(rnn_in)
ulaw_prob = md(gru_out)
gru_out1, _ = rnn(rnn_in)
gru_out2, _ = rnn2(gru_out1)
ulaw_prob = md(gru_out2)
model = Model([pcm, exc, feat, pitch], ulaw_prob)
encoder = Model([feat, pitch], cfeat)
dec_rnn_in = Concatenate()([cpcm, cexc, dec_feat])
dec_gru_out, state = rnn(dec_rnn_in, initial_state=dec_state)
dec_ulaw_prob = md(dec_gru_out)
dec_gru_out1, state1 = rnn(dec_rnn_in, initial_state=dec_state1)
dec_gru_out2, state2 = rnn2(dec_gru_out1, initial_state=dec_state2)
dec_ulaw_prob = md(dec_gru_out2)
decoder = Model([pcm, exc, dec_feat, dec_state], [dec_ulaw_prob, state])
decoder = Model([pcm, exc, dec_feat, dec_state1, dec_state2], [dec_ulaw_prob, state1, state2])
return model, encoder, decoder