mirror of
https://github.com/xiph/opus.git
synced 2025-06-02 08:37:43 +00:00
Use real features at the chunk edges rather than zeros
This commit is contained in:
parent
9fd3e45fd3
commit
b2940ed212
3 changed files with 13 additions and 7 deletions
|
@ -113,7 +113,7 @@ class PCMInit(Initializer):
|
|||
'seed': self.seed
|
||||
}
|
||||
|
||||
def new_lpcnet_model(rnn_units1=384, rnn_units2=16, nb_used_features = 38, use_gpu=True):
|
||||
def new_lpcnet_model(rnn_units1=384, rnn_units2=16, nb_used_features = 38, training=False, use_gpu=True):
|
||||
pcm = Input(shape=(None, 3))
|
||||
feat = Input(shape=(None, nb_used_features))
|
||||
pitch = Input(shape=(None, 1))
|
||||
|
@ -121,8 +121,9 @@ def new_lpcnet_model(rnn_units1=384, rnn_units2=16, nb_used_features = 38, use_g
|
|||
dec_state1 = Input(shape=(rnn_units1,))
|
||||
dec_state2 = Input(shape=(rnn_units2,))
|
||||
|
||||
fconv1 = Conv1D(128, 3, padding='same', activation='tanh', name='feature_conv1')
|
||||
fconv2 = Conv1D(128, 3, padding='same', activation='tanh', name='feature_conv2')
|
||||
padding = 'valid' if training else 'same'
|
||||
fconv1 = Conv1D(128, 3, padding=padding, activation='tanh', name='feature_conv1')
|
||||
fconv2 = Conv1D(128, 3, padding=padding, activation='tanh', name='feature_conv2')
|
||||
|
||||
embed = Embedding(256, embed_size, embeddings_initializer=PCMInit(), name='embed_sig')
|
||||
cpcm = Reshape((-1, embed_size*3))(embed(pcm))
|
||||
|
|
|
@ -40,7 +40,7 @@ config = tf.ConfigProto()
|
|||
config.gpu_options.per_process_gpu_memory_fraction = 0.2
|
||||
set_session(tf.Session(config=config))
|
||||
|
||||
model, enc, dec = lpcnet.new_lpcnet_model()
|
||||
model, enc, dec = lpcnet.new_lpcnet_model(use_gpu=False)
|
||||
|
||||
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
||||
#model.summary()
|
||||
|
@ -63,7 +63,7 @@ periods = (.1 + 50*features[:,:,36:37]+100).astype('int16')
|
|||
|
||||
|
||||
|
||||
model.load_weights('lpcnet20g_384_10_G16_02.h5')
|
||||
model.load_weights('lpcnet20h_384_10_G16_80.h5')
|
||||
|
||||
order = 16
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ nb_epochs = 120
|
|||
# Try reducing batch_size if you run out of memory on your GPU
|
||||
batch_size = 64
|
||||
|
||||
model, _, _ = lpcnet.new_lpcnet_model()
|
||||
model, _, _ = lpcnet.new_lpcnet_model(training=True)
|
||||
|
||||
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy'])
|
||||
model.summary()
|
||||
|
@ -89,6 +89,11 @@ features = np.reshape(features, (nb_frames, feature_chunk_size, nb_features))
|
|||
features = features[:, :, :nb_used_features]
|
||||
features[:,:,18:36] = 0
|
||||
|
||||
fpad1 = np.concatenate([features[0:1, 0:2, :], features[:-1, -2:, :]], axis=0)
|
||||
fpad2 = np.concatenate([features[1:, :2, :], features[0:1, -2:, :]], axis=0)
|
||||
features = np.concatenate([fpad1, features, fpad2], axis=1)
|
||||
|
||||
|
||||
periods = (.1 + 50*features[:,:,36:37]+100).astype('int16')
|
||||
|
||||
in_data = np.concatenate([sig, pred, in_exc], axis=-1)
|
||||
|
@ -98,7 +103,7 @@ del pred
|
|||
del in_exc
|
||||
|
||||
# dump models to disk as we go
|
||||
checkpoint = ModelCheckpoint('lpcnet20g_384_10_G16_{epoch:02d}.h5')
|
||||
checkpoint = ModelCheckpoint('lpcnet20h_384_10_G16_{epoch:02d}.h5')
|
||||
|
||||
#model.load_weights('lpcnet9b_384_10_G16_01.h5')
|
||||
model.compile(optimizer=Adam(0.001, amsgrad=True, decay=5e-5), loss='sparse_categorical_crossentropy')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue