Skip to content

Commit

Permalink
edit loss
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanio committed May 13, 2022
1 parent e5850a9 commit a6ae761
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(
self.ctc_decoder = ctc_decoder
self.cal_wer = torchmetrics.WordErrorRate()
self.cfg_optim = cfg_optim
self.criterion = nn.CTCLoss(zero_infinity=True)

def forward(self, inputs):
"""predicting function"""
Expand All @@ -45,7 +46,7 @@ def configure_optimizers(self):
def training_step(self, batch, batch_idx):
inputs, input_lengths, targets, target_lengths = batch
outputs = self.deepspeech(inputs)
loss = F.ctc_loss(
loss = self.criterion(
outputs.permute(1, 0, 2), targets, input_lengths, target_lengths
)

Expand All @@ -57,7 +58,7 @@ def validation_step(self, batch, batch_idx):
inputs, input_lengths, targets, target_lengths = batch

outputs = self.deepspeech(inputs)
loss = F.ctc_loss(
loss = self.criterion(
outputs.permute(1, 0, 2), targets, input_lengths, target_lengths
)

Expand Down Expand Up @@ -86,7 +87,7 @@ def test_step(self, batch, batch_idx):
inputs, input_lengths, targets, target_lengths = batch
outputs = self.deepspeech(inputs)

loss = F.ctc_loss(
loss = self.criterion(
outputs.permute(1, 0, 2), targets, input_lengths, target_lengths
)

Expand Down

0 comments on commit a6ae761

Please sign in to comment.