Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@amazon.com>2023-09-06 21:30:21 +0300
committerJean-Marc Valin <jmvalin@amazon.com>2023-09-13 05:50:48 +0300
commit108b75c4b189ea2eedd8e9cb0a2b56a9b4424466 (patch)
treefc4f06ad47887c65b08b06fed3f1fe06395f4fe4
parentd54b9fb49af339c8ee72a8f54ee7e5beadbd724f (diff)
Randomly double the training sequence length
Helps with stability with little cost in training speed
-rw-r--r--dnn/torch/fargan/dataset.py9
-rw-r--r--dnn/torch/fargan/train_fargan.py8
2 files changed, 14 insertions, 3 deletions
diff --git a/dnn/torch/fargan/dataset.py b/dnn/torch/fargan/dataset.py
index f33bed36..6195c6af 100644
--- a/dnn/torch/fargan/dataset.py
+++ b/dnn/torch/fargan/dataset.py
@@ -20,16 +20,19 @@ class FARGANDataset(torch.utils.data.Dataset):
self.data = np.memmap(signal_file, dtype='int16', mode='r')
#self.data = self.data[1::2]
- self.nb_sequences = len(self.data)//(pcm_chunk_size)-1
+ self.nb_sequences = len(self.data)//(pcm_chunk_size)-4
self.data = self.data[(4-self.lookahead)*self.frame_size:]
self.data = self.data[:self.nb_sequences*pcm_chunk_size]
- self.data = np.reshape(self.data, (self.nb_sequences, pcm_chunk_size))
+ #self.data = np.reshape(self.data, (self.nb_sequences, pcm_chunk_size))
+ sizeof = self.data.strides[-1]
+ self.data = np.lib.stride_tricks.as_strided(self.data, shape=(self.nb_sequences, pcm_chunk_size*2),
+ strides=(pcm_chunk_size*sizeof, sizeof))
self.features = np.reshape(np.memmap(feature_file, dtype='float32', mode='r'), (-1, nb_features))
sizeof = self.features.strides[-1]
- self.features = np.lib.stride_tricks.as_strided(self.features, shape=(self.nb_sequences, self.sequence_length+4, nb_features),
+ self.features = np.lib.stride_tricks.as_strided(self.features, shape=(self.nb_sequences, self.sequence_length*2+4, nb_features),
strides=(self.sequence_length*self.nb_features*sizeof, self.nb_features*sizeof, sizeof))
self.periods = np.round(50*self.features[:,:,self.nb_used_features-2]+100).astype('int')
diff --git a/dnn/torch/fargan/train_fargan.py b/dnn/torch/fargan/train_fargan.py
index b4eef6fd..852b87be 100644
--- a/dnn/torch/fargan/train_fargan.py
+++ b/dnn/torch/fargan/train_fargan.py
@@ -118,6 +118,14 @@ if __name__ == '__main__':
features = features.to(device)
lpc = lpc.to(device)
periods = periods.to(device)
+ if (np.random.rand() > 0.1):
+ target = target[:, :sequence_length*160]
+ lpc = lpc[:,:sequence_length,:]
+ else:
+ target=target[::2, :]
+ lpc=lpc[::2,:]
+ features=features[::2,:]
+ periods=periods[::2,:]
target = target.to(device)
target = fargan.analysis_filter(target, lpc[:,:,:], gamma=args.gamma)