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:
authorJan Buethe <jbuethe@amazon.de>2024-01-19 19:33:53 +0300
committerJan Buethe <jbuethe@amazon.de>2024-01-19 19:33:53 +0300
commit80eb7ca500f8edfc63f98ca26002d4f938197006 (patch)
treea42e93a4152f17c3a9d3ab0732e7538f761eab20
parentc9b55b260bc4b1e4c5b14ea038376a90292ce091 (diff)
-rw-r--r--dnn/torch/osce/models/silk_feature_net_pl.py25
-rw-r--r--dnn/torch/osce/sparsification_trial.py48
2 files changed, 4 insertions, 69 deletions
diff --git a/dnn/torch/osce/models/silk_feature_net_pl.py b/dnn/torch/osce/models/silk_feature_net_pl.py
index 89e5cc6b..c766d0ab 100644
--- a/dnn/torch/osce/models/silk_feature_net_pl.py
+++ b/dnn/torch/osce/models/silk_feature_net_pl.py
@@ -50,9 +50,7 @@ class SilkFeatureNetPL(nn.Module):
softquant=False,
sparsify=True,
sparsification_density=0.5,
- apply_weight_norm=False,
- repeat_upsamp=False,
- repeat_upsamp_dim=16):
+ apply_weight_norm=False):
super(SilkFeatureNetPL, self).__init__()
@@ -62,17 +60,12 @@ class SilkFeatureNetPL(nn.Module):
self.feature_dim = feature_dim
self.num_channels = num_channels
self.hidden_feature_dim = hidden_feature_dim
- self.repeat_upsamp = repeat_upsamp
- self.repeat_upsamp_dim = 16
norm = weight_norm if apply_weight_norm else lambda x, name=None: x
self.conv1 = norm(nn.Conv1d(feature_dim, self.hidden_feature_dim, 1))
self.conv2 = norm(nn.Conv1d(4 * self.hidden_feature_dim, num_channels, 2))
- if self.repeat_upsamp:
- self.upsamp_embedding = nn.Embedding(4, self.repeat_upsamp_dim)
- else:
- self.tconv = norm(nn.ConvTranspose1d(num_channels, num_channels, 4, 4))
+ self.tconv = norm(nn.ConvTranspose1d(num_channels, num_channels, 4, 4))
gru_input_dim = num_channels + self.repeat_upsamp_dim if self.repeat_upsamp else num_channels
self.gru = norm(norm(nn.GRU(gru_input_dim, num_channels, batch_first=True), name='weight_hh_l0'), name='weight_ih_l0')
@@ -127,18 +120,8 @@ class SilkFeatureNetPL(nn.Module):
c = torch.tanh(self.conv2(F.pad(c, [1, 0])))
# upsampling
- if self.repeat_upsamp:
- a = torch.arange(num_frames, device=features.device) % 4
- embeddings = torch.repeat_interleave(
- torch.tanh(self.upsamp_embedding(a)).unsqueeze(0),
- batch_size,
- 0
- )
- c = c.permute(0, 2, 1)
- c = torch.cat((torch.repeat_interleave(c, 4, 1), embeddings), dim=2)
- else:
- c = torch.tanh(self.tconv(c))
- c = c.permute(0, 2, 1)
+ c = torch.tanh(self.tconv(c))
+ c = c.permute(0, 2, 1)
c, _ = self.gru(c, state)
diff --git a/dnn/torch/osce/sparsification_trial.py b/dnn/torch/osce/sparsification_trial.py
deleted file mode 100644
index 99c01adf..00000000
--- a/dnn/torch/osce/sparsification_trial.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import subprocess
-import argparse
-import sys
-import os
-
-import torch
-import yaml
-
-from utils.templates import nolace_setup
-
-
-parser = argparse.ArgumentParser()
-parser.add_argument('density', type=float)
-parser.add_argument('output', type=str)
-parser.add_argument('--pos-offset', type=int, default=1)
-parser.add_argument('--num-gpus', type=int, default=torch.cuda.device_count())
-parser.add_argument('--dataset-path', type=str, default=None)
-parser.add_argument('--testdata', type=str, default=None)
-
-
-if __name__ == "__main__":
- args = parser.parse_args()
- os.makedirs(args.output, exist_ok=True)
- setup = nolace_setup
- procs = []
- if args.dataset_path is not None:
- setup['dataset'] = os.path.join(args.dataset_path, 'training')
- setup['validation_dataset'] = os.path.join(args.dataset_path, 'validation')
-
- setup['model']['kwargs']['sparsify'] = True
- for cuda_idx in range(args.num_gpus):
- densities = 9*[1]
- densities[cuda_idx+args.pos_offset] = args.density
- setup['model']['kwargs']['sparsification_density'] = densities
- setup['model']['kwargs']['sparsification_schedule'] = [10000, 30000, 100]
-
- output_folder = os.path.join(args.output, f"nolace_d{args.density}_p{cuda_idx+args.pos_offset}")
- setup_path = os.path.join(args.output, f"setup_d{args.density}_p{cuda_idx+args.pos_offset}.yml")
- with open(setup_path, "w") as f:
- f.write(yaml.dump(setup))
-
- trainmodel = os.path.join(os.path.split(__file__)[0], "train_model.py")
- cmd = [sys.executable, trainmodel, setup_path, output_folder, "--device", f"cuda:{cuda_idx}"]
- if args.testdata is not None:
- cmd += ['--testdata', args.testdata]
-
- procs.append(subprocess.Popen(" ".join(cmd), shell=True))
- print(procs[-1].pid)