MCPcopy Index your code
hub / github.com/huggingface/diffusers / __init__

Method __init__

src/diffusers/models/downsampling.py:40–60  ·  view source on GitHub ↗
(
        self,
        channels: int,
        use_conv: bool = False,
        out_channels: int | None = None,
        padding: int = 1,
        name: str = "conv",
    )

Source from the content-addressed store, hash-verified

38 """
39
40 def __init__(
41 self,
42 channels: int,
43 use_conv: bool = False,
44 out_channels: int | None = None,
45 padding: int = 1,
46 name: str = "conv",
47 ):
48 super().__init__()
49 self.channels = channels
50 self.out_channels = out_channels or channels
51 self.use_conv = use_conv
52 self.padding = padding
53 stride = 2
54 self.name = name
55
56 if use_conv:
57 self.conv = nn.Conv1d(self.channels, self.out_channels, 3, stride=stride, padding=padding)
58 else:
59 assert self.channels == self.out_channels
60 self.conv = nn.AvgPool1d(kernel_size=stride, stride=stride)
61
62 def forward(self, inputs: torch.Tensor) -> torch.Tensor:
63 assert inputs.shape[1] == self.channels

Callers 4

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected