Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
표시
레이아웃
나란히 보기
합쳐 보기
실시간 편집
공백 변경 숨기기
변경 없는 행 숨기기
줄바꿈 비활성화
비교 단위
스마트
구문
없음
모양 변경
처리
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
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
비교하기