MCPcopy Create free account
hub / github.com/JuliaWolleb/diffusion-anomaly / __init__

Method __init__

guided_diffusion/unet.py:693–868  ·  view source on GitHub ↗
(
        self,
        image_size,
        in_channels,
        model_channels,
        out_channels,
        num_res_blocks,
        attention_resolutions,
        dropout=0,
        channel_mult=(1, 2, 4, 8),
        conv_resample=True,
        dims=2,
        use_checkpoint=False,
        use_fp16=False,
        num_heads=1,
        num_head_channels=-1,
        num_heads_upsample=-1,
        use_scale_shift_norm=False,
        resblock_updown=False,
        use_new_attention_order=False,
        pool="adaptive",
    )

Source from the content-addressed store, hash-verified

691 """
692
693 def __init__(
694 self,
695 image_size,
696 in_channels,
697 model_channels,
698 out_channels,
699 num_res_blocks,
700 attention_resolutions,
701 dropout=0,
702 channel_mult=(1, 2, 4, 8),
703 conv_resample=True,
704 dims=2,
705 use_checkpoint=False,
706 use_fp16=False,
707 num_heads=1,
708 num_head_channels=-1,
709 num_heads_upsample=-1,
710 use_scale_shift_norm=False,
711 resblock_updown=False,
712 use_new_attention_order=False,
713 pool="adaptive",
714 ):
715 super().__init__()
716
717 if num_heads_upsample == -1:
718 num_heads_upsample = num_heads
719
720 self.in_channels = in_channels
721 self.model_channels = model_channels
722 self.out_channels = out_channels
723 self.num_res_blocks = num_res_blocks
724 self.attention_resolutions = attention_resolutions
725 self.dropout = dropout
726 self.channel_mult = channel_mult
727 self.conv_resample = conv_resample
728 self.use_checkpoint = use_checkpoint
729 self.dtype = th.float16 if use_fp16 else th.float32
730 self.num_heads = num_heads
731 self.num_head_channels = num_head_channels
732 self.num_heads_upsample = num_heads_upsample
733
734 time_embed_dim = model_channels * 4
735 self.time_embed = nn.Sequential(
736 linear(model_channels, time_embed_dim),
737 nn.SiLU(),
738 linear(time_embed_dim, time_embed_dim),
739 )
740
741 self.input_blocks = nn.ModuleList(
742 [
743 TimestepEmbedSequential(
744 conv_nd(dims, in_channels, model_channels, 3, padding=1)
745 )
746 ]
747 )
748 self._feature_size = model_channels
749 input_block_chans = [model_channels]
750 ch = model_channels

Callers

nothing calls this directly

Calls 10

linearFunction · 0.85
conv_ndFunction · 0.85
ResBlockClass · 0.85
AttentionBlockClass · 0.85
DownsampleClass · 0.85
normalizationFunction · 0.85
zero_moduleFunction · 0.85
AttentionPool2dClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected