Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Display
Layout
Split
Unified
Real-time editor
Hide whitespace changes
Hide unchanged lines
Disable line wrap
Diff precision
Smart
Syntax
None
Change appearance
Process
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Layer
Created
5 years ago
Diff never expires
Clear
Export
Share
Explain
7 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
48 lines
Copy
0 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
48 lines
Copy
Copy
Copied
Copy
Copied
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."""
Copy
Copied
Copy
Copied
def __init__(self, config: ViT
MAE
Config, **kwargs):
def __init__(self, config: ViT
Config, **kwargs):
super().__init__(**kwargs)
super().__init__(**kwargs)
Copy
Copied
Copy
Copied
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(
Copy
Copied
Copy
Copied
# 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
Copy
Copied
Copy
Copied
# 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
Saved diffs
Original text
Open file
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
Changed text
Open file
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
Find difference