From 088e025470d23e02310afa0fb422207f0589f298 Mon Sep 17 00:00:00 2001 From: Dom <97384583+tosemml@users.noreply.github.com> Date: Tue, 15 Aug 2023 02:42:49 -0700 Subject: [PATCH 1/2] use np.cumsum --- src/training/dcc_tf.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/training/dcc_tf.py b/src/training/dcc_tf.py index 46d915f..41c71eb 100644 --- a/src/training/dcc_tf.py +++ b/src/training/dcc_tf.py @@ -7,6 +7,8 @@ import torch.nn as nn import torch.nn.functional as F import torch.optim as optim +import numpy as np + from torchmetrics.functional import( scale_invariant_signal_noise_ratio as si_snr, signal_noise_ratio as snr, @@ -80,10 +82,7 @@ def __init__(self, channels, num_layers, kernel_size=3): for i in range(num_layers)] # Compute buffer start indices for each layer - self.buf_indices = [0] - for i in range(num_layers - 1): - self.buf_indices.append( - self.buf_indices[-1] + self.buf_lengths[i]) + self.buf_indices = np.cumsum(self.buf_lengths[:(num_layers - 1)]).tolist() # Dilated causal conv layers aggregate previous context to obtain # contexful encoded input. From c9b59da67b1dfcbcf7f6d9a3e0a659ce039d416d Mon Sep 17 00:00:00 2001 From: Dom <97384583+tosemml@users.noreply.github.com> Date: Tue, 15 Aug 2023 02:46:59 -0700 Subject: [PATCH 2/2] Update dcc_tf.py --- src/training/dcc_tf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/training/dcc_tf.py b/src/training/dcc_tf.py index 41c71eb..918c7e1 100644 --- a/src/training/dcc_tf.py +++ b/src/training/dcc_tf.py @@ -82,7 +82,7 @@ def __init__(self, channels, num_layers, kernel_size=3): for i in range(num_layers)] # Compute buffer start indices for each layer - self.buf_indices = np.cumsum(self.buf_lengths[:(num_layers - 1)]).tolist() + self.buf_indices = [0] + np.cumsum(self.buf_lengths[:(num_layers - 1)]).tolist() # Dilated causal conv layers aggregate previous context to obtain # contexful encoded input.