Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
表示
レイアウト
分割
統合
ライブエディター
空白の変更を非表示
未変更行を折りたたむ
折り返しなし
比較精度
スマート
構文
なし
外観を変更
処理
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
Layer
作成日
5 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
7 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
48 行
すべてコピー
0 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
48 行
すべてコピー
コピー
コピー済み
コピー
コピー済み
class TFViT
MAE
Layer(tf.keras.layers.Layer):
class TFViT
Layer(tf.keras.layers.Layer):
"""This corresponds to the Block class in the timm implementation."""
"""This corresponds to the Block class in the timm implementation."""
コピー
コピー済み
コピー
コピー済み
def __init__(self, config: ViT
MAE
Config, **kwargs):
def __init__(self, config: ViT
Config, **kwargs):
super().__init__(**kwargs)
super().__init__(**kwargs)
コピー
コピー済み
コピー
コピー済み
self.attention = TFViT
MAE
Attention(config, name="attention")
self.attention = TFViT
Attention(config, name="attention")
self.intermediate = TFViT
MAE
Intermediate(config, name="intermediate")
self.intermediate = TFViT
Intermediate(config, name="intermediate")
self.vit_output = TFViT
MAE
Output(config, name="output")
self.vit_output = TFViT
Output(config, name="output")
self.layernorm_before = tf.keras.layers.LayerNormalization(
self.layernorm_before = tf.keras.layers.LayerNormalization(
epsilon=config.layer_norm_eps, name="layernorm_before"
epsilon=config.layer_norm_eps, name="layernorm_before"
)
)
self.layernorm_after = tf.keras.layers.LayerNormalization(
self.layernorm_after = tf.keras.layers.LayerNormalization(
epsilon=config.layer_norm_eps, name="layernorm_after"
epsilon=config.layer_norm_eps, name="layernorm_after"
)
)
def call(
def call(
self,
self,
hidden_states: tf.Tensor,
hidden_states: tf.Tensor,
head_mask: tf.Tensor,
head_mask: tf.Tensor,
output_attentions: bool,
output_attentions: bool,
training: bool = False,
training: bool = False,
) -> Tuple[tf.Tensor]:
) -> Tuple[tf.Tensor]:
attention_outputs = self.attention(
attention_outputs = self.attention(
コピー
コピー済み
コピー
コピー済み
# in ViT
MAE
, layernorm is applied before self-attention
# in ViT
, layernorm is applied before self-attention
input_tensor=self.layernorm_before(inputs=hidden_states),
input_tensor=self.layernorm_before(inputs=hidden_states),
head_mask=head_mask,
head_mask=head_mask,
output_attentions=output_attentions,
output_attentions=output_attentions,
training=training,
training=training,
)
)
attention_output = attention_outputs[0]
attention_output = attention_outputs[0]
# first residual connection
# first residual connection
hidden_states = attention_output + hidden_states
hidden_states = attention_output + hidden_states
コピー
コピー済み
コピー
コピー済み
# in ViT
MAE
, layernorm is also applied after self-attention
# in ViT
, layernorm is also applied after self-attention
layer_output = self.layernorm_after(inputs=hidden_states)
layer_output = self.layernorm_after(inputs=hidden_states)
intermediate_output = self.intermediate(hidden_states=layer_output)
intermediate_output = self.intermediate(hidden_states=layer_output)
# second residual connection is done here
# second residual connection is done here
layer_output = self.vit_output(
layer_output = self.vit_output(
hidden_states=intermediate_output, input_tensor=hidden_states, training=training
hidden_states=intermediate_output, input_tensor=hidden_states, training=training
)
)
outputs = (layer_output,) + attention_outputs[1:] # add attentions if we output them
outputs = (layer_output,) + attention_outputs[1:] # add attentions if we output them
return outputs
return outputs
保存された差分
原文
ファイルを開く
class TFViTMAELayer(tf.keras.layers.Layer): """This corresponds to the Block class in the timm implementation.""" def __init__(self, config: ViTMAEConfig, **kwargs): super().__init__(**kwargs) self.attention = TFViTMAEAttention(config, name="attention") self.intermediate = TFViTMAEIntermediate(config, name="intermediate") self.vit_output = TFViTMAEOutput(config, name="output") self.layernorm_before = tf.keras.layers.LayerNormalization( epsilon=config.layer_norm_eps, name="layernorm_before" ) self.layernorm_after = tf.keras.layers.LayerNormalization( epsilon=config.layer_norm_eps, name="layernorm_after" ) def call( self, hidden_states: tf.Tensor, head_mask: tf.Tensor, output_attentions: bool, training: bool = False, ) -> Tuple[tf.Tensor]: attention_outputs = self.attention( # in ViT MAE, layernorm is applied before self-attention input_tensor=self.layernorm_before(inputs=hidden_states), head_mask=head_mask, output_attentions=output_attentions, training=training, ) attention_output = attention_outputs[0] # first residual connection hidden_states = attention_output + hidden_states # in ViT MAE, layernorm is also applied after self-attention layer_output = self.layernorm_after(inputs=hidden_states) intermediate_output = self.intermediate(hidden_states=layer_output) # second residual connection is done here layer_output = self.vit_output( hidden_states=intermediate_output, input_tensor=hidden_states, training=training ) outputs = (layer_output,) + attention_outputs[1:] # add attentions if we output them return outputs
変更されたテキスト
ファイルを開く
class TFViTLayer(tf.keras.layers.Layer): """This corresponds to the Block class in the timm implementation.""" def __init__(self, config: ViTConfig, **kwargs): super().__init__(**kwargs) self.attention = TFViTAttention(config, name="attention") self.intermediate = TFViTIntermediate(config, name="intermediate") self.vit_output = TFViTOutput(config, name="output") self.layernorm_before = tf.keras.layers.LayerNormalization( epsilon=config.layer_norm_eps, name="layernorm_before" ) self.layernorm_after = tf.keras.layers.LayerNormalization( epsilon=config.layer_norm_eps, name="layernorm_after" ) def call( self, hidden_states: tf.Tensor, head_mask: tf.Tensor, output_attentions: bool, training: bool = False, ) -> Tuple[tf.Tensor]: attention_outputs = self.attention( # in ViT, layernorm is applied before self-attention input_tensor=self.layernorm_before(inputs=hidden_states), head_mask=head_mask, output_attentions=output_attentions, training=training, ) attention_output = attention_outputs[0] # first residual connection hidden_states = attention_output + hidden_states # in ViT, layernorm is also applied after self-attention layer_output = self.layernorm_after(inputs=hidden_states) intermediate_output = self.intermediate(hidden_states=layer_output) # second residual connection is done here layer_output = self.vit_output( hidden_states=intermediate_output, input_tensor=hidden_states, training=training ) outputs = (layer_output,) + attention_outputs[1:] # add attentions if we output them return outputs
違いを見つける