MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / FlaxDecoder

Class FlaxDecoder

diffusers/src/diffusers/models/vae_flax.py:574–686  ·  view source on GitHub ↗

r""" Flax Implementation of VAE Decoder. This model is a Flax Linen [flax.linen.Module](https://flax.readthedocs.io/en/latest/flax.linen.html#module) subclass. Use it as a regular Flax linen Module and refer to the Flax documentation for all matter related to general usage and behav

Source from the content-addressed store, hash-verified

572
573
574class FlaxDecoder(nn.Module):
575 r"""
576 Flax Implementation of VAE Decoder.
577
578 This model is a Flax Linen [flax.linen.Module](https://flax.readthedocs.io/en/latest/flax.linen.html#module)
579 subclass. Use it as a regular Flax linen Module and refer to the Flax documentation for all matter related to
580 general usage and behavior.
581
582 Finally, this model supports inherent JAX features such as:
583 - [Just-In-Time (JIT) compilation](https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit)
584 - [Automatic Differentiation](https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation)
585 - [Vectorization](https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap)
586 - [Parallelization](https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap)
587
588 Parameters:
589 in_channels (:obj:`int`, *optional*, defaults to 3):
590 Input channels
591 out_channels (:obj:`int`, *optional*, defaults to 3):
592 Output channels
593 up_block_types (:obj:`Tuple[str]`, *optional*, defaults to `(UpDecoderBlock2D)`):
594 UpDecoder block type
595 block_out_channels (:obj:`Tuple[str]`, *optional*, defaults to `(64,)`):
596 Tuple containing the number of output channels for each block
597 layers_per_block (:obj:`int`, *optional*, defaults to `2`):
598 Number of Resnet layer for each block
599 norm_num_groups (:obj:`int`, *optional*, defaults to `32`):
600 norm num group
601 act_fn (:obj:`str`, *optional*, defaults to `silu`):
602 Activation function
603 double_z (:obj:`bool`, *optional*, defaults to `False`):
604 Whether to double the last output channels
605 dtype (:obj:`jnp.dtype`, *optional*, defaults to jnp.float32):
606 parameters `dtype`
607 """
608
609 in_channels: int = 3
610 out_channels: int = 3
611 up_block_types: Tuple[str] = ("UpDecoderBlock2D",)
612 block_out_channels: int = (64,)
613 layers_per_block: int = 2
614 norm_num_groups: int = 32
615 act_fn: str = "silu"
616 dtype: jnp.dtype = jnp.float32
617
618 def setup(self):
619 block_out_channels = self.block_out_channels
620
621 # z to block_in
622 self.conv_in = nn.Conv(
623 block_out_channels[-1],
624 kernel_size=(3, 3),
625 strides=(1, 1),
626 padding=((1, 1), (1, 1)),
627 dtype=self.dtype,
628 )
629
630 # middle
631 self.mid_block = FlaxUNetMidBlock2D(

Callers 1

setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected