Commit 1634ed01 authored by proxyphi's avatar proxyphi Committed by Facebook GitHub Bot
Browse files

[BC-breaking] Fix momentum in transforms.GriffinLim (#2568)

Summary:
The momentum in GriffinLim transform is modified before being passed
to the functional. causing inconsistency between functional and transforms.

Fix this by making it pass through in transform.

Fixes https://github.com/pytorch/audio/issues/2567

Pull Request resolved: https://github.com/pytorch/audio/pull/2568

Reviewed By: nateanl

Differential Revision: D38117632

Pulled By: mthrok

fbshipit-source-id: 99754be4b3b6dea45ba115aaea9fb6d7285bc2c9
parent 8dcf06ac
...@@ -264,6 +264,7 @@ def griffinlim( ...@@ -264,6 +264,7 @@ def griffinlim(
""" """
assert momentum < 1, "momentum={} > 1 can be unstable".format(momentum) assert momentum < 1, "momentum={} > 1 can be unstable".format(momentum)
assert momentum >= 0, "momentum={} < 0".format(momentum) assert momentum >= 0, "momentum={} < 0".format(momentum)
momentum = momentum / (1 + momentum)
# pack batch # pack batch
shape = specgram.size() shape = specgram.size()
...@@ -302,7 +303,7 @@ def griffinlim( ...@@ -302,7 +303,7 @@ def griffinlim(
# Update our phase estimates # Update our phase estimates
angles = rebuilt angles = rebuilt
if momentum: if momentum:
angles = angles - tprev.mul_(momentum / (1 + momentum)) angles = angles - tprev.mul_(momentum)
angles = angles.div(angles.abs().add(1e-16)) angles = angles.div(angles.abs().add(1e-16))
# Store the previous iterate # Store the previous iterate
......
...@@ -264,7 +264,7 @@ class GriffinLim(torch.nn.Module): ...@@ -264,7 +264,7 @@ class GriffinLim(torch.nn.Module):
self.register_buffer("window", window) self.register_buffer("window", window)
self.length = length self.length = length
self.power = power self.power = power
self.momentum = momentum / (1 + momentum) self.momentum = momentum
self.rand_init = rand_init self.rand_init = rand_init
def forward(self, specgram: Tensor) -> Tensor: def forward(self, specgram: Tensor) -> Tensor:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment