Skip to content

Commit 05fe555

Browse files
committed
Fixes to Hubert issues that cause problems later
1 parent 410f995 commit 05fe555

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/transformers/models/hubert/modeling_tf_hubert.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ def _normalize_kernel(self):
416416

417417
def build(self, input_shape):
418418
if not self.built:
419-
input_shape = input_shape.as_list()
420-
# If a specific input shape is passed in, we need to modify it to account for padding
421-
# Not necessary if those portions of the shape are None
422-
if input_shape[-2] is not None:
423-
input_shape[-2] += self.explicit_padding * 2
424419
super().build(input_shape)
425420

426421
self.kernel = tf.Variable(tf.transpose(self.kernel), name="weight_v", trainable=True)
@@ -531,13 +526,17 @@ def __init__(self, config: HubertConfig, **kwargs: Any) -> None:
531526
)
532527
self.padding = TFHubertSamePadLayer(config.num_conv_pos_embeddings)
533528
self.activation = get_tf_activation(config.feat_extract_activation)
529+
self.config = config
534530

535531
def call(self, hidden_states: tf.Tensor) -> tf.Tensor:
536532
hidden_states = self.conv(hidden_states)
537533
hidden_states = self.padding(hidden_states)
538534
hidden_states = self.activation(hidden_states)
539535
return hidden_states
540536

537+
def build(self, input_shape=None):
538+
self.conv.build(self.config.hidden_size)
539+
541540

542541
# Copied from transformers.models.wav2vec2.modeling_tf_wav2vec2.TFWav2Vec2SamePadLayer with Wav2Vec2->Hubert
543542
class TFHubertSamePadLayer(tf.keras.layers.Layer):

0 commit comments

Comments
 (0)