Skip to content

Commit

Permalink
removed envelope loss
Browse files Browse the repository at this point in the history
  • Loading branch information
AznamirWoW committed Jan 8, 2025
1 parent 7537108 commit 5ed5d41
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
10 changes: 0 additions & 10 deletions rvc/train/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,3 @@ def kl_loss(z_p, logs_q, m_p, logs_p, z_mask):
kl = (kl * z_mask).sum()
loss = kl / z_mask.sum()
return loss


MaxPool = torch.nn.MaxPool1d(160)


def envelope_loss(y, y_g):
loss = 0
loss += torch.mean(torch.abs(MaxPool(y) - MaxPool(y_g)))
loss += torch.mean(torch.abs(MaxPool(-y) - MaxPool(-y_g)))
return loss
10 changes: 1 addition & 9 deletions rvc/train/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
feature_loss,
generator_loss,
kl_loss,
envelope_loss,
)
from mel_processing import (
mel_spectrogram_torch,
Expand Down Expand Up @@ -100,7 +99,6 @@
"gen_loss_queue": deque(maxlen=10),
"disc_loss_queue": deque(maxlen=10),
"disc_loss_50": deque(maxlen=50),
"env_loss_50": deque(maxlen=50),
"fm_loss_50": deque(maxlen=50),
"kl_loss_50": deque(maxlen=50),
"mel_loss_50": deque(maxlen=50),
Expand Down Expand Up @@ -681,11 +679,10 @@ def train_and_evaluate(
_, y_d_hat_g, fmap_r, fmap_g = net_d(wave, y_hat)

loss_mel = fn_mel_loss(wave, y_hat) * config.train.c_mel / 3.0
loss_env = envelope_loss(wave, y_hat)
loss_kl = kl_loss(z_p, logs_q, m_p, logs_p, z_mask) * config.train.c_kl
loss_fm = feature_loss(fmap_r, fmap_g)
loss_gen, _ = generator_loss(y_d_hat_g)
loss_gen_all = loss_gen + loss_fm + loss_mel + loss_kl + loss_env
loss_gen_all = loss_gen + loss_fm + loss_mel + loss_kl

if loss_gen_all < lowest_value["value"]:
lowest_value = {
Expand All @@ -705,7 +702,6 @@ def train_and_evaluate(

# queue for rolling losses over 50 steps
avg_losses["disc_loss_50"].append(loss_disc.detach())
avg_losses["env_loss_50"].append(loss_env.detach())
avg_losses["fm_loss_50"].append(loss_fm.detach())
avg_losses["kl_loss_50"].append(loss_kl.detach())
avg_losses["mel_loss_50"].append(loss_mel.detach())
Expand All @@ -717,9 +713,6 @@ def train_and_evaluate(
"loss_avg_50/d/total": torch.mean(
torch.stack(list(avg_losses["disc_loss_50"]))
),
"loss_avg_50/g/env": torch.mean(
torch.stack(list(avg_losses["env_loss_50"]))
),
"loss_avg_50/g/fm": torch.mean(
torch.stack(list(avg_losses["fm_loss_50"]))
),
Expand Down Expand Up @@ -793,7 +786,6 @@ def train_and_evaluate(
"loss/g/fm": loss_fm,
"loss/g/mel": loss_mel,
"loss/g/kl": loss_kl,
"loss/g/env": loss_env,
"loss_avg_epoch/disc": np.mean(avg_losses["disc_loss_queue"]),
"loss_avg_epoch/gen": np.mean(avg_losses["gen_loss_queue"]),
}
Expand Down

0 comments on commit 5ed5d41

Please sign in to comment.