mirror of
https://github.com/xiph/opus.git
synced 2025-05-21 10:58:30 +00:00
deeper features
This commit is contained in:
parent
639766b322
commit
ea1391e174
3 changed files with 13 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
import math
|
||||
from keras.models import Model
|
||||
from keras.layers import Input, LSTM, CuDNNGRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Bidirectional, MaxPooling1D, Activation
|
||||
from keras.layers import Input, LSTM, CuDNNGRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation
|
||||
from keras import backend as K
|
||||
from keras.initializers import Initializer
|
||||
from mdense import MDense
|
||||
|
@ -47,14 +47,14 @@ def new_wavernn_model():
|
|||
pitch = Input(shape=(None, 1))
|
||||
feat = Input(shape=(None, nb_used_features))
|
||||
pitch = Input(shape=(None, 1))
|
||||
dec_feat = Input(shape=(None, 32))
|
||||
dec_feat = Input(shape=(None, 128))
|
||||
dec_state = Input(shape=(rnn_units,))
|
||||
|
||||
conv1 = Conv1D(16, 7, padding='causal', activation='tanh')
|
||||
pconv1 = Conv1D(16, 5, padding='same', activation='tanh')
|
||||
pconv2 = Conv1D(16, 5, padding='same', activation='tanh')
|
||||
fconv1 = Conv1D(128, 3, padding='same', activation='tanh')
|
||||
fconv2 = Conv1D(32, 3, padding='same', activation='tanh')
|
||||
fconv2 = Conv1D(102, 3, padding='same', activation='tanh')
|
||||
|
||||
if False:
|
||||
cpcm = conv1(pcm)
|
||||
|
@ -73,6 +73,12 @@ def new_wavernn_model():
|
|||
|
||||
cfeat = fconv2(fconv1(cat_feat))
|
||||
|
||||
fdense1 = Dense(128, activation='tanh')
|
||||
fdense2 = Dense(128, activation='tanh')
|
||||
|
||||
cfeat = Add()([cfeat, cat_feat])
|
||||
cfeat = fdense2(fdense1(cfeat))
|
||||
|
||||
rep = Lambda(lambda x: K.repeat_elements(x, 160, 1))
|
||||
|
||||
rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True)
|
||||
|
|
|
@ -66,7 +66,7 @@ in_data = np.reshape(in_data, (nb_frames*pcm_chunk_size, 1))
|
|||
out_data = np.reshape(data, (nb_frames*pcm_chunk_size, 1))
|
||||
|
||||
|
||||
model.load_weights('wavenet4d2_203.h5')
|
||||
model.load_weights('wavenet4f3_30.h5')
|
||||
|
||||
order = 16
|
||||
|
||||
|
@ -75,7 +75,7 @@ fexc = np.zeros((1, 1, 2), dtype='float32')
|
|||
iexc = np.zeros((1, 1, 1), dtype='int16')
|
||||
state = np.zeros((1, lpcnet.rnn_units), dtype='float32')
|
||||
for c in range(1, nb_frames):
|
||||
cfeat = enc.predict(features[c:c+1, :, :nb_used_features])
|
||||
cfeat = enc.predict([features[c:c+1, :, :nb_used_features], periods[c:c+1, :, :]])
|
||||
for fr in range(1, feature_chunk_size):
|
||||
f = c*feature_chunk_size + fr
|
||||
a = features[c, fr, nb_features-order:]
|
||||
|
|
|
@ -104,8 +104,8 @@ in_data = np.concatenate([in_data, pred], axis=-1)
|
|||
# f.create_dataset('data', data=in_data[:50000, :, :])
|
||||
# f.create_dataset('feat', data=features[:50000, :, :])
|
||||
|
||||
checkpoint = ModelCheckpoint('wavenet4e_{epoch:02d}.h5')
|
||||
checkpoint = ModelCheckpoint('wavenet4f3_{epoch:02d}.h5')
|
||||
|
||||
#model.load_weights('wavernn1c_01.h5')
|
||||
#model.load_weights('wavenet4f2_30.h5')
|
||||
model.compile(optimizer=Adam(0.001, amsgrad=True, decay=2e-4), loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
||||
model.fit([in_data, in_exc, features, periods], out_data, batch_size=batch_size, epochs=30, validation_split=0.2, callbacks=[checkpoint])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue