4326582bb1e68480ef79a02abbf4bfacc3aadede,layers/losses.py,MSELossMasked,forward,#MSELossMasked#Any#Any#Any#,39
Before Change
// logits_flat: (batch * max_len, dim)
input = input.view(-1, input.shape[-1])
// target_flat: (batch * max_len, dim)
target_flat = target.view(-1, target.shape[-1])
// losses_flat: (batch * max_len, dim)
losses_flat = functional.mse_loss(
input, target_flat, size_average=False, reduce=False)
// losses: (batch, max_len, dim)
losses = losses_flat.view(*target.size())
// mask: (batch, max_len, 1)
mask = sequence_mask(
After Change
loss: An average loss value masked by the length.
// mask: (batch, max_len, 1)
mask = sequence_mask(
sequence_length=length, max_len=target.size(1)).unsqueeze(2).float()
mask = mask.expand_as(input)
loss = functional.mse_loss(
input * mask, target * mask, reduction="sum")
loss = loss / mask.sum()
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: mozilla/TTS
Commit Name: 4326582bb1e68480ef79a02abbf4bfacc3aadede
Time: 2019-03-06
Author: egolge@mozilla.com
File Name: layers/losses.py
Class Name: MSELossMasked
Method Name: forward
Project Name: mozilla/TTS
Commit Name: a15b3ec9a18377bf67356a9b5c29f4b767001d05
Time: 2018-08-13
Author: erengolge@gmail.com
File Name: layers/losses.py
Class Name: L1LossMasked
Method Name: forward
Project Name: mozilla/TTS
Commit Name: 4326582bb1e68480ef79a02abbf4bfacc3aadede
Time: 2019-03-06
Author: egolge@mozilla.com
File Name: layers/losses.py
Class Name: MSELossMasked
Method Name: forward
Project Name: NVIDIA/sentiment-discovery
Commit Name: 7130245fb45db86263963fe237b40ce1f5b06c73
Time: 2018-11-28
Author: raulp@nvidia.com
File Name: finetune.py
Class Name:
Method Name: get_supervised_batch