SelfOutput

建立於 差異永不過期
3 刪除
19 行
0 新增
19 行
class TFViTMAESelfOutput(tf.keras.layers.Layer):
class TFViTSelfOutput(tf.keras.layers.Layer):
"""
"""
The residual connection is defined in TFViTMAELayer instead of here (as is the case with other models), due to the
The residual connection is defined in TFViTLayer instead of here (as is the case with other models), due to the
layernorm applied before each block.
layernorm applied before each block.
"""
"""


def __init__(self, config: ViTMAEConfig, **kwargs):
def __init__(self, config: ViTConfig, **kwargs):
super().__init__(**kwargs)
super().__init__(**kwargs)


self.dense = tf.keras.layers.Dense(
self.dense = tf.keras.layers.Dense(
units=config.hidden_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
units=config.hidden_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
)
self.dropout = tf.keras.layers.Dropout(rate=config.hidden_dropout_prob)
self.dropout = tf.keras.layers.Dropout(rate=config.hidden_dropout_prob)


def call(self, hidden_states: tf.Tensor, input_tensor: tf.Tensor, training: bool = False) -> tf.Tensor:
def call(self, hidden_states: tf.Tensor, input_tensor: tf.Tensor, training: bool = False) -> tf.Tensor:
hidden_states = self.dense(inputs=hidden_states)
hidden_states = self.dense(inputs=hidden_states)
hidden_states = self.dropout(inputs=hidden_states, training=training)
hidden_states = self.dropout(inputs=hidden_states, training=training)


return hidden_states
return hidden_states