AlexK-PL commited on
Commit
282a36c
·
1 Parent(s): 7e39ad1

Delete logger.py

Browse files
Files changed (1) hide show
  1. logger.py +0 -47
logger.py DELETED
@@ -1,47 +0,0 @@
1
- import random
2
- import torch.nn.functional as F
3
- from tensorboardX import SummaryWriter
4
- from plotting_utils import plot_alignment_to_numpy, plot_gst_scores_to_numpy, plot_spectrogram_to_numpy
5
- from plotting_utils import plot_gate_outputs_to_numpy
6
-
7
-
8
- class Tacotron2Logger(SummaryWriter):
9
- def __init__(self, logdir):
10
- super(Tacotron2Logger, self).__init__(logdir)
11
-
12
- def log_training(self, reduced_loss, grad_norm, learning_rate, duration,
13
- iteration):
14
- self.add_scalar("training.loss", reduced_loss, iteration)
15
- self.add_scalar("grad.norm", grad_norm, iteration)
16
- self.add_scalar("learning.rate", learning_rate, iteration)
17
- self.add_scalar("duration", duration, iteration)
18
-
19
- def log_validation(self, reduced_loss, model, y, y_pred, gst_scores, iteration):
20
- self.add_scalar("validation.loss", reduced_loss, iteration)
21
- _, mel_outputs, gate_outputs, alignments, _ = y_pred
22
- mel_targets, gate_targets = y
23
-
24
- # plot distribution of parameters
25
- for tag, value in model.named_parameters():
26
- tag = tag.replace('.', '/')
27
- self.add_histogram(tag, value.data.cpu().numpy(), iteration)
28
-
29
- # plot alignment, mel target and predicted, gate target and predicted
30
- idx = random.randint(0, alignments.size(0) - 1)
31
-
32
- align_idx = alignments[idx].data.cpu().numpy().T
33
- gst_scores = gst_scores.data.cpu().numpy().T
34
- # print("Validation GST scores before plotting to tensorboard: {}".format(gst_scores.shape))
35
- meltarg_idx = mel_targets[idx].data.cpu().numpy()
36
- melout_idx = mel_outputs[idx].data.cpu().numpy()
37
-
38
- self.add_image("alignment", plot_alignment_to_numpy(align_idx), iteration)
39
- self.add_image("gst_scores", plot_gst_scores_to_numpy(gst_scores), iteration)
40
- self.add_image("mel_target", plot_spectrogram_to_numpy(meltarg_idx), iteration)
41
- self.add_image("mel_predicted", plot_spectrogram_to_numpy(melout_idx), iteration)
42
- self.add_image(
43
- "gate",
44
- plot_gate_outputs_to_numpy(
45
- gate_targets[idx].data.cpu().numpy(),
46
- F.sigmoid(gate_outputs[idx]).data.cpu().numpy()),
47
- iteration)