MCPcopy Create free account
hub / github.com/huggingface/diffusers / Conv1dBlock

Class Conv1dBlock

src/diffusers/models/resnet.py:392–424  ·  view source on GitHub ↗

Conv1d --> GroupNorm --> Mish Parameters: inp_channels (`int`): Number of input channels. out_channels (`int`): Number of output channels. kernel_size (`int` or `tuple`): Size of the convolving kernel. n_groups (`int`, default `8`): Number of groups to separ

Source from the content-addressed store, hash-verified

390
391
392class Conv1dBlock(nn.Module):
393 """
394 Conv1d --> GroupNorm --> Mish
395
396 Parameters:
397 inp_channels (`int`): Number of input channels.
398 out_channels (`int`): Number of output channels.
399 kernel_size (`int` or `tuple`): Size of the convolving kernel.
400 n_groups (`int`, default `8`): Number of groups to separate the channels into.
401 activation (`str`, defaults to `mish`): Name of the activation function.
402 """
403
404 def __init__(
405 self,
406 inp_channels: int,
407 out_channels: int,
408 kernel_size: int | tuple[int, int],
409 n_groups: int = 8,
410 activation: str = "mish",
411 ):
412 super().__init__()
413
414 self.conv1d = nn.Conv1d(inp_channels, out_channels, kernel_size, padding=kernel_size // 2)
415 self.group_norm = nn.GroupNorm(n_groups, out_channels)
416 self.mish = get_activation(activation)
417
418 def forward(self, inputs: torch.Tensor) -> torch.Tensor:
419 intermediate_repr = self.conv1d(inputs)
420 intermediate_repr = rearrange_dims(intermediate_repr)
421 intermediate_repr = self.group_norm(intermediate_repr)
422 intermediate_repr = rearrange_dims(intermediate_repr)
423 output = self.mish(intermediate_repr)
424 return output
425
426
427# unet_rl.py

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…