Skip to content

Commit d055dae

Browse files
feat: add noiser bottleneck
1 parent cfe358f commit d055dae

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

audio_diffusion_pytorch/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .modules import (
3232
AutoEncoder1d,
3333
MultiEncoder1d,
34+
Noiser,
3435
T5Embedder,
3536
Tanh,
3637
UNet1d,

audio_diffusion_pytorch/modules.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,20 @@ def forward(
13501350
return (x, info) if with_info else x
13511351

13521352

1353+
class Noiser(Bottleneck):
1354+
def __init__(self, sigma: float = 1.0):
1355+
super().__init__()
1356+
self.sigma = sigma
1357+
1358+
def forward(
1359+
self, x: Tensor, with_info: bool = False
1360+
) -> Union[Tensor, Tuple[Tensor, Any]]:
1361+
if self.training:
1362+
x = torch.randn_like(x) * self.sigma + x
1363+
info: Dict = dict()
1364+
return (x, info) if with_info else x
1365+
1366+
13531367
class AutoEncoder1d(nn.Module):
13541368
def __init__(
13551369
self,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name="audio-diffusion-pytorch",
55
packages=find_packages(exclude=[]),
6-
version="0.0.71",
6+
version="0.0.72",
77
license="MIT",
88
description="Audio Diffusion - PyTorch",
99
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)