reduce memory use of training code

pull/8/head
Jean-Marc Valin 2018-12-09 21:21:30 -05:00
parent 8267c0e876
commit 343de214e8
No known key found for this signature in database
GPG Key ID: 5E5DD9A36F9189C8
1 changed files with 7 additions and 0 deletions

View File

@ -86,7 +86,9 @@ features = features[:nb_frames*feature_chunk_size*nb_features]
in_data = np.concatenate([data[0:1], data[:-1]]);
noise = np.concatenate([np.zeros((len(data)*1//5)), np.random.randint(-3, 3, len(data)*1//5), np.random.randint(-2, 2, len(data)*1//5), np.random.randint(-1, 1, len(data)*2//5)])
#noise = np.round(np.concatenate([np.zeros((len(data)*1//5)), np.random.laplace(0, 1.2, len(data)*1//5), np.random.laplace(0, .77, len(data)*1//5), np.random.laplace(0, .33, len(data)*1//5), np.random.randint(-1, 1, len(data)*1//5)]))
del data
in_data = in_data + noise
del noise
in_data = np.clip(in_data, 0, 255)
features = np.reshape(features, (nb_frames*feature_chunk_size, nb_features))
@ -105,6 +107,7 @@ for i in range(2, nb_frames*feature_chunk_size):
for k in range(16):
upred[i*frame_size:(i+1)*frame_size] = upred[i*frame_size:(i+1)*frame_size] - \
pred_in[i*frame_size-k:(i+1)*frame_size-k]*features[i, nb_features-16+k]
del pred_in
pred = lin2ulaw(upred)
@ -116,6 +119,8 @@ in_data = in_data.astype('uint8')
# ideal excitation in_exc
out_data = lin2ulaw(udata-upred)
del upred
del udata
in_exc = np.concatenate([out_data[0:1], out_data[:-1]]);
out_data = np.reshape(out_data, (nb_frames, pcm_chunk_size, 1))
@ -135,6 +140,8 @@ periods = (50*features[:,:,36:37]+100).astype('int16')
in_data = np.concatenate([in_data, pred], axis=-1)
del pred
# dump models to disk as we go
checkpoint = ModelCheckpoint('lpcnet14_384_10_G16_{epoch:02d}.h5')