Skip to content

Commit

Permalink
fix accidental eps change
Browse files Browse the repository at this point in the history
  • Loading branch information
neggles committed Jul 13, 2024
1 parent b9c9068 commit af528f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/neurosis/modules/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from torch.utils.checkpoint import checkpoint

from neurosis.modules.diffusion.util import zero_module
from neurosis.modules.layers import Normalize

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -153,7 +152,7 @@ def __init__(self, in_channels: int):
super().__init__()
self.in_channels = in_channels

self.norm = Normalize(in_channels)
self.norm = nn.GroupNorm(num_groups=32, num_channels=in_channels, eps=1e-6, affine=True)
self.q = nn.Conv2d(in_channels, in_channels, kernel_size=1, stride=1, padding=0)
self.k = nn.Conv2d(in_channels, in_channels, kernel_size=1, stride=1, padding=0)
self.v = nn.Conv2d(in_channels, in_channels, kernel_size=1, stride=1, padding=0)
Expand Down Expand Up @@ -610,7 +609,7 @@ def __init__(
context_dim = [None] * depth

self.in_channels = in_channels
self.norm = Normalize(in_channels)
self.norm = nn.GroupNorm(num_groups=32, num_channels=in_channels, eps=1e-6, affine=True)

inner_dim = n_heads * d_head
if not use_linear:
Expand Down
9 changes: 4 additions & 5 deletions src/neurosis/modules/diffusion/openaimodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
timestep_embedding,
zero_module,
)
from neurosis.modules.layers import Normalize

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -246,7 +245,7 @@ def __init__(
padding = kernel_size // 2

self.in_layers = nn.Sequential(
Normalize(channels),
nn.GroupNorm(32, channels),
nn.SiLU(),
conv_nd(dims, channels, self.out_channels, kernel_size, padding=padding),
)
Expand Down Expand Up @@ -280,7 +279,7 @@ def __init__(
)

self.out_layers = nn.Sequential(
Normalize(self.out_channels),
nn.GroupNorm(32, self.out_channels),
nn.SiLU(),
nn.Dropout(p=dropout),
zero_module(
Expand Down Expand Up @@ -368,7 +367,7 @@ def __init__(
), f"q,k,v channels {channels} is not divisible by num_head_channels {num_head_channels}"
self.num_heads = channels // num_head_channels
self.use_checkpoint = use_checkpoint
self.norm = Normalize(channels)
self.norm = nn.GroupNorm(channels)
self.qkv = conv_nd(1, channels, channels * 3, 1)
if use_new_attention_order:
# split qkv before split heads
Expand Down Expand Up @@ -796,7 +795,7 @@ def __init__(
self._feature_size += ch

self.out = nn.Sequential(
Normalize(ch),
nn.GroupNorm(32, ch),
nn.SiLU(),
zero_module(conv_nd(dims, model_channels, out_channels, 3, padding=1)),
)
Expand Down

0 comments on commit af528f9

Please sign in to comment.