(self, x, mask=None)
| 737 | return out |
| 738 | |
| 739 | def forward(self, x, mask=None): |
| 740 | x = x.transpose(1, 2) |
| 741 | if mask is not None: |
| 742 | mask = (mask.int() == 0).squeeze(1) |
| 743 | max_len = x.shape[1] |
| 744 | slf_attn_mask = ( |
| 745 | mask.unsqueeze(1).expand(-1, max_len, -1) if mask is not None else None |
| 746 | ) |
| 747 | |
| 748 | # spectral |
| 749 | x = self.spectral(x) |
| 750 | # temporal |
| 751 | x = x.transpose(1, 2) |
| 752 | x = self.temporal(x) |
| 753 | x = x.transpose(1, 2) |
| 754 | # self-attention |
| 755 | if mask is not None: |
| 756 | x = x.masked_fill(mask.unsqueeze(-1), 0) |
| 757 | x, _ = self.slf_attn(x, mask=slf_attn_mask) |
| 758 | # fc |
| 759 | x = self.fc(x) |
| 760 | # temoral average pooling |
| 761 | w = self.temporal_avg_pool(x, mask=mask) |
| 762 | |
| 763 | return w.unsqueeze(-1) |
| 764 | |
| 765 | |
| 766 | class MelStyleEncoderVAE(nn.Module): |
nothing calls this directly
no test coverage detected