Skip to content

Commit

Permalink
needs to be zero centered GP
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jan 12, 2025
1 parent 6740714 commit 2154a74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions audiolm_pytorch/soundstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def hinge_gen_loss(fake):
def leaky_relu(p = 0.1):
return nn.LeakyReLU(p)

def gradient_penalty(wave, output, weight = 10):
def gradient_penalty(wave, output, weight = 10, center = 0.):
batch_size, device = wave.shape[0], wave.device

gradients = torch_grad(
Expand All @@ -80,7 +80,7 @@ def gradient_penalty(wave, output, weight = 10):
)[0]

gradients = rearrange(gradients, 'b ... -> b (...)')
return weight * ((vector_norm(gradients, dim = 1) - 1) ** 2).mean()
return weight * ((vector_norm(gradients, dim = 1) - center) ** 2).mean()

# better sequential

Expand Down
2 changes: 1 addition & 1 deletion audiolm_pytorch/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.3.0'
__version__ = '2.3.1'

0 comments on commit 2154a74

Please sign in to comment.