Diffusers documentation

DiTTransformer2DModel

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

DiTTransformer2DModel

DiTからの画像類似データ向けの Transformer モデル。

DiTTransformer2DModel

class diffusers.DiTTransformer2DModel

< >

( num_attention_heads: int = 16attention_head_dim: int = 72in_channels: int = 4out_channels: int | None = Nonenum_layers: int = 28dropout: float = 0.0norm_num_groups: int = 32attention_bias: bool = Truesample_size: int = 32patch_size: int = 2activation_fn: str = 'gelu-approximate'num_embeds_ada_norm: int | None = 1000upcast_attention: bool = Falsenorm_type: str = 'ada_norm_zero'norm_elementwise_affine: bool = Falsenorm_eps: float = 1e-05 )

パラメータ

  • num_attention_heads (int, 任意、デフォルトは 16) — マルチヘッドアテンションに使用するヘッド数。
  • attention_head_dim (int, 任意、デフォルトは 72) — 各ヘッドのチャネル数。
  • in_channels (int, デフォルトは 4) — 入力データのチャネル数。
  • out_channels (int, optional) — 出力のチャネル数。入力のチャネル数と異なる場合は、このパラメータを指定してください。
  • num_layers (int, 任意、デフォルトは 28) — 使用する Transformer ブロックの層数。
  • dropout (float, 任意、デフォルトは 0.0) — Transformer ブロック内で使用する dropout の確率。
  • norm_num_groups (int, 任意、デフォルトは 32) — Transformer ブロック内のグループ正規化におけるグループ数。
  • attention_bias (bool, 任意、デフォルトは True) — Transformer ブロックの attention に bias パラメータを含めるかどうかを設定します。
  • sample_size (int, デフォルトは 32) — 潜在画像の幅です。このパラメータは学習中に固定されます。
  • patch_size (int, デフォルトは 2) — モデルが処理するパッチのサイズです。シーケンスでないデータを扱うアーキテクチャに関連します。
  • activation_fn (str, optional, デフォルトは “gelu-approximate”) — Transformer ブロック内のフィードフォワードネットワークで使用する活性化関数。
  • num_embeds_ada_norm (int, optional, デフォルト値は 1000) — AdaLayerNorm に使用される埋め込みの数です。学習中に固定され、推論時の最大デノイジングステップ数に影響します。
  • upcast_attention (bool, optional, デフォルトは False) — true の場合、パフォーマンスの向上を目的として、attention メカニズムの次元をアップキャストします。
  • norm_type (str, optional, defaults to “ada_norm_zero”) — 使用する正規化の種類を指定します。‘ada_norm_zero’ を指定できます。
  • norm_elementwise_affine (bool, optional, デフォルトは False) — True の場合、正規化レイヤーで要素ごとのアフィンパラメータを有効にします。
  • norm_eps (float, optional, デフォルトは 1e-5) — 正規化レイヤーの分母に追加される小さな定数で、ゼロ除算を防ぐために使用されます。

DiT(https://huggingface.co/papers/2212.09748)で紹介された2次元Transformerモデル。

forward

< >

( hidden_states: Tensortimestep: typing.Optional[torch.LongTensor] = Noneclass_labels: typing.Optional[torch.LongTensor] = Nonecross_attention_kwargs: dict = Nonereturn_dict: bool = True )

パラメータ

  • hidden_states(離散型の場合は torch.LongTensor(shape: (batch size, num latent pixels))、連続型の場合は torch.FloatTensor(shape: (batch size, channel, height, width)))— 入力となる hidden_states。
  • timestep ( torch.LongTensor, 任意) — デノイジングステップを示すために使用します。AdaLayerNorm内で埋め込みとして適用される任意のタイムステップです。
  • class_labels ( torch.LongTensor、形状 (batch size, num classes)、任意) — クラスラベルの条件付けを示すために使用します。AdaLayerZeroNorm内で埋め込みとして適用される任意のクラスラベルです。
  • cross_attention_kwargs ( dict[str, Any]、省略可) — 指定された場合、diffusers.models.attention_processor で定義されている self.processor 配下の AttentionProcessor に渡される kwargs の辞書です。
  • return_dict (bool、任意、デフォルトは True) — プレーンなタプルではなく UNet2DConditionOutput を返すかどうか。

DiTTransformer2DModelのforwardメソッドです。

Update on GitHub