mirror of
https://github.com/xiph/opus.git
synced 2025-05-28 14:19:13 +00:00
Making it easier to adapt (or not) a model
This commit is contained in:
parent
edee9cd8f2
commit
219fbff4e6
1 changed files with 17 additions and 3 deletions
|
@ -105,6 +105,20 @@ del in_exc
|
|||
# dump models to disk as we go
|
||||
checkpoint = ModelCheckpoint('lpcnet24g_384_10_G16_{epoch:02d}.h5')
|
||||
|
||||
model.load_weights('lpcnet24c_384_10_G16_120.h5')
|
||||
model.compile(optimizer=Adam(0.0001, amsgrad=True), loss='sparse_categorical_crossentropy')
|
||||
model.fit([in_data, features, periods], out_exc, batch_size=batch_size, epochs=nb_epochs, validation_split=0.0, callbacks=[checkpoint, lpcnet.Sparsify(0, 0, 1, (0.05, 0.05, 0.2))])
|
||||
#Set this to True to adapt an existing model (e.g. on new data)
|
||||
adaptation = False
|
||||
|
||||
if adaptation:
|
||||
#Adapting from an existing model
|
||||
model.load_weights('lpcnet24c_384_10_G16_120.h5')
|
||||
sparsify = lpcnet.Sparsify(0, 0, 1, (0.05, 0.05, 0.2))
|
||||
lr = 0.0001
|
||||
decay = 0
|
||||
else:
|
||||
#Training from scratch
|
||||
sparsify = lpcnet.Sparsify(2000, 40000, 400, (0.05, 0.05, 0.2))
|
||||
lr = 0.001
|
||||
decay = 5e-5
|
||||
|
||||
model.compile(optimizer=Adam(lr, amsgrad=True, decay=decay), loss='sparse_categorical_crossentropy')
|
||||
model.fit([in_data, features, periods], out_exc, batch_size=batch_size, epochs=nb_epochs, validation_split=0.0, callbacks=[checkpoint, sparsify])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue