Skip to content

Commit

Permalink
feat: add noisy autoencoder option
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioschneider committed Sep 28, 2022
1 parent 5950759 commit c5ac204
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion audio_diffusion_pytorch/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,11 +1118,13 @@ def __init__(
multipliers: Sequence[int],
factors: Sequence[int],
num_blocks: Sequence[int],
use_noisy: bool = False,
bottleneck: Optional[Bottleneck] = None,
):
super().__init__()
num_layers = len(multipliers) - 1
self.bottleneck = bottleneck
self.use_noisy = use_noisy

assert len(factors) >= num_layers and len(num_blocks) >= num_layers

Expand Down Expand Up @@ -1150,7 +1152,7 @@ def __init__(
self.upsamples = nn.ModuleList(
[
UpsampleBlock1d(
in_channels=channels * multipliers[i + 1],
in_channels=channels * multipliers[i + 1] * (use_noisy + 1),
out_channels=channels * multipliers[i],
factor=factors[i],
num_groups=resnet_groups,
Expand Down Expand Up @@ -1183,6 +1185,8 @@ def encode(

def decode(self, x: Tensor) -> Tensor:
for upsample in self.upsamples:
if self.use_noisy:
x = torch.cat([x, torch.randn_like(x)], dim=1)
x = upsample(x)
return self.to_out(x)

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.50",
version="0.0.51",
license="MIT",
description="Audio Diffusion - PyTorch",
long_description_content_type="text/markdown",
Expand Down

0 comments on commit c5ac204

Please sign in to comment.