From 6966265af66318dd84d358dbba40c35cef76511a Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 6 Dec 2023 20:46:30 +0000 Subject: [PATCH] make fix-copies --- src/transformers/models/electra/modeling_tf_electra.py | 3 ++- src/transformers/models/hubert/modeling_tf_hubert.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/transformers/models/electra/modeling_tf_electra.py b/src/transformers/models/electra/modeling_tf_electra.py index 6be10609c753e1..b5bbe23191006a 100644 --- a/src/transformers/models/electra/modeling_tf_electra.py +++ b/src/transformers/models/electra/modeling_tf_electra.py @@ -546,6 +546,7 @@ def __init__(self, config: ElectraConfig, **kwargs): activation="tanh", name="dense", ) + self.config = config def call(self, hidden_states: tf.Tensor) -> tf.Tensor: # We "pool" the model by simply taking the hidden state corresponding @@ -561,7 +562,7 @@ def build(self, input_shape=None): self.built = True if getattr(self, "dense", None) is not None: with tf.name_scope(self.dense.name): - self.dense.build(None) + self.dense.build(self.config.hidden_size) # Copied from transformers.models.albert.modeling_tf_albert.TFAlbertEmbeddings with Albert->Electra diff --git a/src/transformers/models/hubert/modeling_tf_hubert.py b/src/transformers/models/hubert/modeling_tf_hubert.py index 5585e1e66a56a7..6062059575483f 100644 --- a/src/transformers/models/hubert/modeling_tf_hubert.py +++ b/src/transformers/models/hubert/modeling_tf_hubert.py @@ -568,8 +568,9 @@ def build(self, input_shape=None): if self.built: return self.built = True - with tf.name_scope(self.conv.name): - self.conv.build(self.config.hidden_size) + if getattr(self, "conv", None) is not None: + with tf.name_scope(self.conv.name): + self.conv.build(self.config.hidden_size) # Copied from transformers.models.wav2vec2.modeling_tf_wav2vec2.TFWav2Vec2SamePadLayer with Wav2Vec2->Hubert