SelfOutput

Criado O diff nunca expira
3 remoções
19 linhas
0 adições
19 linhas
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