Skip to content

Commit

Permalink
feat: add noiser bottleneck
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioschneider committed Oct 23, 2022
1 parent cfe358f commit d055dae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions audio_diffusion_pytorch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from .modules import (
AutoEncoder1d,
MultiEncoder1d,
Noiser,
T5Embedder,
Tanh,
UNet1d,
Expand Down
14 changes: 14 additions & 0 deletions audio_diffusion_pytorch/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,20 @@ def forward(
return (x, info) if with_info else x


class Noiser(Bottleneck):
def __init__(self, sigma: float = 1.0):
super().__init__()
self.sigma = sigma

def forward(
self, x: Tensor, with_info: bool = False
) -> Union[Tensor, Tuple[Tensor, Any]]:
if self.training:
x = torch.randn_like(x) * self.sigma + x
info: Dict = dict()
return (x, info) if with_info else x


class AutoEncoder1d(nn.Module):
def __init__(
self,
Expand Down
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.71",
version="0.0.72",
license="MIT",
description="Audio Diffusion - PyTorch",
long_description_content_type="text/markdown",
Expand Down

0 comments on commit d055dae

Please sign in to comment.