Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion monai/networks/nets/diffusion_model_unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import math
from collections.abc import Sequence
from typing import Optional

import torch
from torch import nn
Expand Down Expand Up @@ -2005,7 +2006,7 @@ def __init__(

self.down_blocks.append(down_block)

self.out = nn.Sequential(nn.Linear(4096, 512), nn.ReLU(), nn.Dropout(0.1), nn.Linear(512, self.out_channels))
self.out: Optional[nn.Module] = None

def forward(
self,
Expand Down Expand Up @@ -2048,6 +2049,12 @@ def forward(
h, _ = downsample_block(hidden_states=h, temb=emb, context=context)

h = h.reshape(h.shape[0], -1)

# 5. out
if self.out is None:
self.out = nn.Sequential(
nn.Linear(h.shape[1], 512), nn.ReLU(), nn.Dropout(0.1), nn.Linear(512, self.out_channels)
)
output: torch.Tensor = self.out(h)

return output
Loading