# Is there a way to access layers in TFBertMainLayer?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-there-a-way-to-access-layers-in-tfbertmainlayer%2F5438%3E%5C
**Category:** 🤗Transformers\
**Created:** [April 12, 2021, 1:59pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-there-a-way-to-access-layers-in-tfbertmainlayer%2F5438 "2021-04-12T13:59:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexeyK](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@AlexeyK](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAlexeyK)%5C
**Post date:** [April 12, 2021, 1:59pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fis-there-a-way-to-access-layers-in-tfbertmainlayer%2F5438%2F1 "2021-04-12T13:59:13Z")

</div>

Here is the output of the pre-trained BERT, model.layers =  
[\<transformers.models.bert.modeling\_tf\_bert.TFBertMainLayer at 0x7f1d5628ac90\>, \<tensorflow.python.keras.layers.core.Dropout at 0x7f1d51c04cd0\>, \<tensorflow.python.keras.layers.core.Dense at 0x7f1d51c04f50\>] .

Is there a way to access layers in TFBertMainLayer? In particular, I would like to try a particular regularization method for the tokens Embedding() layer, i.e. I would like to access TFBertEmbeddings and the embedding layer that is self.token\_type\_embeddings = tf.keras.layers.Embedding(  
config.type\_vocab\_size,  
config.hidden\_size,  
embeddings\_initializer=get\_initializer(self.initializer\_range),  
name=“token\_type\_embeddings”,  
)  
with the purpose of setting ‘embeddings\_regularizer=’ to a specific value.
