Skip to content

Commit

Permalink
black format
Browse files Browse the repository at this point in the history
  • Loading branch information
zyingt committed Feb 22, 2024
1 parent 4c62032 commit 9a743be
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 24 deletions.
4 changes: 1 addition & 3 deletions evaluation/metrics/similarity/models/RawNetModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def forward(self, x):
w = self.attention(global_x)

mu = torch.sum(x * w, dim=2)
sg = torch.sqrt(
(torch.sum((x**2) * w, dim=2) - mu**2).clamp(min=1e-4, max=1e4)
)
sg = torch.sqrt((torch.sum((x**2) * w, dim=2) - mu**2).clamp(min=1e-4, max=1e4))

x = torch.cat((mu, sg), 1)

Expand Down
6 changes: 2 additions & 4 deletions models/tta/autoencoder/autoencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ def forward(self, x):


# TODO: Encoder1d
class Encoder1d(Encoder2d):
...
class Encoder1d(Encoder2d): ...


class Decoder2d(nn.Module):
Expand Down Expand Up @@ -351,8 +350,7 @@ def forward(self, z):


# TODO: decoder1d
class Decoder1d(Decoder2d):
...
class Decoder1d(Decoder2d): ...


class AutoencoderKL(nn.Module):
Expand Down
6 changes: 2 additions & 4 deletions models/tta/autoencoder/autoencoder_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def __call__(self, batch):
return packed_batch_features


class AutoencoderKLTestDataset(BaseTestDataset):
...
class AutoencoderKLTestDataset(BaseTestDataset): ...


class AutoencoderKLTestCollator(BaseTestCollator):
...
class AutoencoderKLTestCollator(BaseTestCollator): ...
6 changes: 2 additions & 4 deletions models/tta/ldm/audioldm_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ def __call__(self, batch):
return packed_batch_features


class AudioLDMTestDataset(BaseTestDataset):
...
class AudioLDMTestDataset(BaseTestDataset): ...


class AudioLDMTestCollator(BaseTestCollator):
...
class AudioLDMTestCollator(BaseTestCollator): ...
4 changes: 1 addition & 3 deletions modules/diffusion/karras/karras_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ def to_d(x, sigma, denoised):
def get_ancestral_step(sigma_from, sigma_to):
"""Calculates the noise level (sigma_down) to step down to and the amount
of noise to add (sigma_up) when doing an ancestral sampling step."""
sigma_up = (
sigma_to**2 * (sigma_from**2 - sigma_to**2) / sigma_from**2
) ** 0.5
sigma_up = (sigma_to**2 * (sigma_from**2 - sigma_to**2) / sigma_from**2) ** 0.5
sigma_down = (sigma_to**2 - sigma_up**2) ** 0.5
return sigma_down, sigma_up

Expand Down
4 changes: 1 addition & 3 deletions modules/transformer/mh_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,7 @@ def forward(
(
1
if key_padding_mask is not None
else 0
if attn_mask is not None
else None
else 0 if attn_mask is not None else None
),
)

Expand Down
4 changes: 1 addition & 3 deletions optimizer/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,7 @@ def _size_update(

denom = scale_exp_avg_sq.sqrt() + eps

scale_step = (
-size_lr * (bias_correction2**0.5) * scale_grads.sum(dim=0) / denom
)
scale_step = -size_lr * (bias_correction2**0.5) * scale_grads.sum(dim=0) / denom

is_too_small = param_rms < param_min_rms
is_too_large = param_rms > param_max_rms
Expand Down

0 comments on commit 9a743be

Please sign in to comment.