@@ -778,18 +778,12 @@ def _dp_forward(
778778 The (log) likelihood of each utterance in the batch.
779779 """
780780 # useful values
781- # batch_size = len(phn_lens_abs)
782781 U_max = phn_lens_abs .max ()
783- # fb_max_length = lens_abs.max()
784782 device = emiss_pred_useful .device
785783
786784 pi_prob = pi_prob .to (device )
787785 trans_prob = trans_prob .to (device )
788786
789- # alpha_matrix = self.neg_inf * torch.ones(
790- # [batch_size, U_max, fb_max_length]
791- # ).to(device)
792-
793787 # for cropping alpha_matrix later
794788 phn_len_mask = torch .arange (U_max )[None , :].to (device ) < phn_lens_abs [
795789 :, None
@@ -809,25 +803,6 @@ def _dp_forward(
809803 phn_len_mask , alpha_prev , torch .tensor ([- 1e38 ]).to (device )
810804 )
811805
812- # for t in range(1, fb_max_length):
813- # alpha_times_trans = batch_log_matvecmul(
814- # trans_prob.permute(0, 2, 1), alpha_matrix[:, :, t - 1]
815- # )
816- # alpha_matrix[:, :, t] = (
817- # alpha_times_trans + emiss_pred_useful[:, :, t]
818- # )
819- #
820- # # crop alpha_matrix
821- # alpha_matrix = torch.where(
822- # phn_len_mask[:, :, None],
823- # alpha_matrix,
824- # torch.tensor(self.neg_inf).to(device),
825- # )
826- #
827- # sum_alpha_T = torch.logsumexp(
828- # alpha_matrix[torch.arange(batch_size), :, -1], dim=1
829- # )
830-
831806 sum_alpha_T = torch .logsumexp (alpha_prev , dim = - 1 )
832807
833808 return sum_alpha_T
@@ -955,14 +930,6 @@ def _dp_viterbi(
955930 z_stars .append (z_star_i )
956931 z_stars_loc .append (z_star_i_loc )
957932
958- # print("batch alignment statistics:")
959- #
960- # print('phns:', phns[-1])
961- # print("phn_lens_abs:", phn_lens_abs[-1])
962- # print("lens_abs:", lens_abs[-1])
963- # print("z_stars_loc:", z_stars_loc[-1])
964- # print("z_stars:", z_stars[-1])
965- #
966933 # picking out viterbi_scores
967934 viterbi_scores = v_matrix [
968935 torch .arange (batch_size ), phn_lens_abs - 1 , lens_abs - 1
0 commit comments