Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix about tensorboard #516

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions egs/librispeech/ASR/conformer_ctc/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,17 @@ def compute_loss(

info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = supervisions["num_frames"].sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - supervisions["num_frames"]) / feature.size(1))
.sum()
.item()
)

return loss, info


Expand Down
9 changes: 9 additions & 0 deletions egs/librispeech/ASR/conformer_ctc2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@ def compute_loss(
# Note: We use reduction=sum while computing the loss.
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = feature_lens.sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - feature_lens) / feature.size(1)).sum().item()
)

return loss, info


Expand Down
11 changes: 11 additions & 0 deletions egs/librispeech/ASR/streaming_conformer_ctc/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,17 @@ def compute_loss(

info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = supervisions["num_frames"].sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - supervisions["num_frames"]) / feature.size(1))
.sum()
.item()
)

return loss, info


Expand Down
11 changes: 11 additions & 0 deletions egs/librispeech/ASR/tdnn_lstm_ctc/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,17 @@ def compute_loss(
info["frames"] = supervision_segments[:, 2].sum().item()
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = supervisions["num_frames"].sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(2) - supervisions["num_frames"]) / feature.size(2))
.sum()
.item()
)

return loss, info


Expand Down
9 changes: 9 additions & 0 deletions egs/librispeech/ASR/transducer/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ def compute_loss(
# Note: We use reduction=sum while computing the loss.
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = feature_lens.sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - feature_lens) / feature.size(1)).sum().item()
)

return loss, info


Expand Down
9 changes: 9 additions & 0 deletions egs/librispeech/ASR/transducer_lstm/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ def compute_loss(
# Note: We use reduction=sum while computing the loss.
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = feature_lens.sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - feature_lens) / feature.size(1)).sum().item()
)

return loss, info


Expand Down
9 changes: 9 additions & 0 deletions egs/librispeech/ASR/transducer_stateless/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,15 @@ def compute_loss(
# Note: We use reduction=sum while computing the loss.
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = feature_lens.sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - feature_lens) / feature.size(1)).sum().item()
)

return loss, info


Expand Down
9 changes: 9 additions & 0 deletions egs/librispeech/ASR/transducer_stateless2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@ def compute_loss(
# Note: We use reduction=sum while computing the loss.
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = feature_lens.sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - feature_lens) / feature.size(1)).sum().item()
)

return loss, info


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,15 @@ def compute_loss(
# Note: We use reduction=sum while computing the loss.
info["loss"] = loss.detach().cpu().item()

# `utt_duration` and `utt_pad_proportion` would be normalized by `utterances` # noqa
info["utterances"] = feature.size(0)
# averaged input duration in frames over utterances
info["utt_duration"] = feature_lens.sum().item()
# averaged padding proportion over utterances
info["utt_pad_proportion"] = (
((feature.size(1) - feature_lens) / feature.size(1)).sum().item()
)

return loss, info


Expand Down
9 changes: 6 additions & 3 deletions icefall/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,13 @@ def intersect(self, lattice: k2.Fsa, use_double_scores=True) -> "Nbest":
if hasattr(lattice, "aux_labels"):
# delete token IDs as it is not needed
del word_fsa.aux_labels
word_fsa_with_epsilon_loops = k2.linear_fsa_with_self_loops(word_fsa)
word_fsa_with_epsilon_loops = k2.linear_fsa_with_self_loops(
word_fsa
)
else:
word_fsa_with_epsilon_loops = k2.linear_fst_with_self_loops(word_fsa)

word_fsa_with_epsilon_loops = k2.linear_fst_with_self_loops(
word_fsa
)

path_to_utt_map = self.shape.row_ids(1)

Expand Down
7 changes: 4 additions & 3 deletions icefall/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,10 @@ def __str__(self) -> str:
else:
raise ValueError(f"Unexpected key: {k}")
frames = "%.2f" % self["frames"]
ans_frames += "over " + str(frames) + " frames; "
utterances = "%.2f" % self["utterances"]
ans_utterances += "over " + str(utterances) + " utterances."
ans_frames += "over " + str(frames) + " frames. "
if ans_utterances != "":
utterances = "%.2f" % self["utterances"]
ans_utterances += "over " + str(utterances) + " utterances."

return ans_frames + ans_utterances

Expand Down