Skip to content

Commit

Permalink
fix: sigmoid norm
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioschneider committed Oct 5, 2022
1 parent 13cddd6 commit d32c307
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions audio_diffusion_pytorch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ def upsample(waveforms: Tensor, factor: int, **kwargs) -> Tensor:

def wave_norm(x: Tensor, peak: float = 0.5, alpha: float = 20.0) -> Tensor:
x = x.clip(-1, 1)
x = torch.sigmoid(alpha * x)
x = 2 * torch.sigmoid(alpha * x) - 1
x = x.clip(-1, 1)
return x * peak


def wave_unnorm(x: Tensor, peak: float = 0.5, alpha: float = 20.0) -> Tensor:
x = x / peak
x = x.clip(-1, 1)
x = (1.0 / alpha) * torch.log(x / (1 - x))
x = (1.0 / alpha) * torch.log((x + 1) / (1 - x))
x = x.clip(-1, 1)
return x
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name="audio-diffusion-pytorch",
packages=find_packages(exclude=[]),
version="0.0.55",
version="0.0.54",
license="MIT",
description="Audio Diffusion - PyTorch",
long_description_content_type="text/markdown",
Expand Down

0 comments on commit d32c307

Please sign in to comment.